get-service-credentials.asciidoc 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. [role="xpack"]
  2. [[security-api-get-service-credentials]]
  3. === Get service account credentials API
  4. beta::[]
  5. ++++
  6. <titleabbrev>Get service account credentials</titleabbrev>
  7. ++++
  8. Retrieves all service credentials for a <<service-accounts,service account>>.
  9. [[security-api-get-service-credentials-request]]
  10. ==== {api-request-title}
  11. `GET /_security/service/<namespace>/<service>/credential`
  12. [[security-api-get-service-credentials-prereqs]]
  13. ==== {api-prereq-title}
  14. * To use this API, you must have at least the `manage_service_account`
  15. <<privileges-list-cluster,cluster privilege>>.
  16. [[security-api-get-service-credentials-desc]]
  17. ==== {api-description-title}
  18. include::../../security/authentication/service-accounts.asciidoc[tag=service-accounts-tls]
  19. Use this API to retrieve a list of credentials for a service account.
  20. The response includes service account tokens that were created with the
  21. << create service account API >> as well as file-backed tokens that
  22. are local to the node.
  23. NOTE: For tokens backed by the `service_tokens` file, the API only returns
  24. tokens defined in the file local to the node against which the request was issued.
  25. [[security-api-get-service-credentials-path-params]]
  26. ==== {api-path-parms-title}
  27. `namespace`::
  28. (Required, string) Name of the namespace.
  29. `service`::
  30. (Required, string) Name of the service name.
  31. [[security-api-get-service-credentials-example]]
  32. ==== {api-examples-title}
  33. The following request uses the <<security-api-create-service-token,create service account token API>> to create a service account token named `token1`
  34. in the `elastic/fleet-server` service account:
  35. [source,console]
  36. ----
  37. POST /_security/service/elastic/fleet-server/credential/token/token1
  38. ----
  39. The following request returns all credentials for the `elastic/fleet-server`
  40. service account:
  41. [source,console]
  42. ----
  43. GET /_security/service/elastic/fleet-server/credential
  44. ----
  45. // TEST[continued]
  46. The response includes all credentials related to the specified service account:
  47. [source,js]
  48. ----
  49. {
  50. "service_account": "elastic/fleet-server",
  51. "node_name": "node0", <1>
  52. "count": 3,
  53. "tokens": {
  54. "token1": {}, <2>
  55. "token42": {} <3>
  56. },
  57. "file_tokens": {
  58. "my-token": {} <4>
  59. }
  60. }
  61. ----
  62. // NOTCONSOLE
  63. <1> The local node name
  64. <2> A new service account token backed by the `.security` index
  65. <3> An existing service account token backed by the `.security` index
  66. <4> A file-backed token local to the `node0` node