|
@@ -0,0 +1,126 @@
|
|
|
+[role="xpack"]
|
|
|
+[[service-accounts]]
|
|
|
+=== Service accounts
|
|
|
+
|
|
|
+beta::[]
|
|
|
+
|
|
|
+The {stack-security-features} provide _service accounts_ specifically for
|
|
|
+integration with external services that connect to {es}, such as {fleet} server.
|
|
|
+Service accounts have a fixed set of privileges and cannot be authenticated
|
|
|
+until you create a service account token for them. Additionally, service
|
|
|
+accounts are predefined in code, and are always enabled.
|
|
|
+
|
|
|
+With service accounts, services (such as {fleet} server) can create a
|
|
|
+service account token, authenticate with that token, and manage their own API keys.
|
|
|
+Multiple service account tokens can be created for the same service account.
|
|
|
+This prevents credential sharing between multiple instances of the same external service.
|
|
|
+That is, these instances can assume the same identity while having their own distinct
|
|
|
+service account tokens for authentication.
|
|
|
+
|
|
|
+=== Service accounts vs built-in users
|
|
|
+Service account is an evolution of the built-in users. It provides
|
|
|
+flexibility over built-in users because they:
|
|
|
+
|
|
|
+* Do not rely on the <<native-realm,internal `native` realm>>, and aren't
|
|
|
+always required to rely on the `.security` index
|
|
|
+* Use a role descriptor named after the service account principal instead of traditional roles
|
|
|
+* Support multiple credentials through service account tokens
|
|
|
+
|
|
|
+Service accounts are not included in the response of the
|
|
|
+<<security-api-get-user,get users API>>. To retrieve a service account, use the
|
|
|
+<<security-api-get-service-accounts,get service accounts API>>.
|
|
|
+
|
|
|
+[[service-accounts-explanation]]
|
|
|
+==== How service accounts work
|
|
|
+Service accounts have a
|
|
|
+<<security-api-get-service-accounts-path-params,unique principal>> that takes
|
|
|
+the format of `<namespace>/<service>`, where the `namespace` is a top-level
|
|
|
+grouping of service accounts, and `service` is the name of the service.
|
|
|
+
|
|
|
+Currently, only one service account is available:
|
|
|
+
|
|
|
+`elastic/fleet-server`:: The service account used by the {fleet} server to
|
|
|
+communicate with {es}.
|
|
|
+
|
|
|
+// tag::service-accounts-usage[]
|
|
|
+IMPORTANT: The predefined service accounts are intended for external services
|
|
|
+connecting to {es}. Do not attempt to use service accounts for authenticating
|
|
|
+individual users.
|
|
|
+// end::service-accounts-usage[]
|
|
|
+
|
|
|
+// tag::service-accounts-tls[]
|
|
|
+In <<dev-vs-prod-mode,production mode>>, service accounts require TLS on the
|
|
|
+HTTP interface. A runtime check prevents you from invoking any related APIs or
|
|
|
+authenticating with a service account token unless TLS is enabled on the HTTP
|
|
|
+interface. See <<encrypt-http-communication,encrypt HTTP client communications for {es}>>.
|
|
|
+// end::service-accounts-tls[]
|
|
|
+
|
|
|
+[[service-accounts-tokens]]
|
|
|
+==== How service account tokens work
|
|
|
+A service account token, or simply service token,
|
|
|
+is a unique string that a service uses to authenticate
|
|
|
+with {es}. For a given service account, each token must have a unique name.
|
|
|
+Because tokens include access credentials, they should always be kept secret
|
|
|
+by whichever client is using them.
|
|
|
+
|
|
|
+Service account tokens can be backed by either the `service_tokens` file or the
|
|
|
+`.security` index. You can create multiple service account tokens for a single
|
|
|
+service account, which enables multiple instances of the same service to run
|
|
|
+with different credentials.
|
|
|
+
|
|
|
+You must create a service account token to use a service account. You can
|
|
|
+create a service account token using either:
|
|
|
+
|
|
|
+* The <<service-tokens-command,elasticsearch-service-tokens>> CLI tool, which
|
|
|
+saves the new service account token in the `$ES_HOME/config/service_tokens` file
|
|
|
+and outputs the bearer token to your terminal
|
|
|
+* The <<security-api-create-service-token,create service account tokens API>>,
|
|
|
+which saves the new service account token in the `.security` index and returns
|
|
|
+the bearer token in the HTTP response
|
|
|
+
|
|
|
+Service account tokens never expire. You must actively <<security-api-delete-service-token,delete>> them if they are no longer needed.
|
|
|
+
|
|
|
+[[authenticate-with-service-account-token]]
|
|
|
+==== Authenticate with service account tokens
|
|
|
+
|
|
|
+NOTE: Service accounts currently do not support basic authentication.
|
|
|
+
|
|
|
+To use a service account token, include the generated token value in a request
|
|
|
+with an `Authorization: Bearer` header:
|
|
|
+
|
|
|
+[source,shell]
|
|
|
+----
|
|
|
+curl -H "Authorization: Bearer AAEAAWVsYXN0aWM...vZmxlZXQtc2VydmVyL3Rva2VuMTo3TFdaSDZ" http://localhost:9200/_security/_authenticate
|
|
|
+----
|
|
|
+// NOTCONSOLE
|
|
|
+
|
|
|
+A successful authentication response includes a `token` field, which contains a
|
|
|
+`name` for the name of the service account token:
|
|
|
+
|
|
|
+[source,js]
|
|
|
+----
|
|
|
+{
|
|
|
+ "username": "elastic/fleet-server",
|
|
|
+ "roles": [],
|
|
|
+ "full_name": "Service account - elastic/fleet-server",
|
|
|
+ "email": null,
|
|
|
+ "token": {
|
|
|
+ "name": "token1" <1>
|
|
|
+ },
|
|
|
+ "metadata": {
|
|
|
+ "_elastic_service_account": true
|
|
|
+ },
|
|
|
+ "enabled": true,
|
|
|
+ "authentication_realm": {
|
|
|
+ "name": "service_account",
|
|
|
+ "type": "service_account"
|
|
|
+ },
|
|
|
+ "lookup_realm": {
|
|
|
+ "name": "service_account",
|
|
|
+ "type": "service_account"
|
|
|
+ },
|
|
|
+ "authentication_type": "token"
|
|
|
+}
|
|
|
+----
|
|
|
+// NOTCONSOLE
|
|
|
+<1> Name of the service account token
|