Skip to content

Commit d37a49e

Browse files
authored
Add token based authn documentation in stack docs (#195)
This commit adds documentation for token-based authentication services like token-service and api-key-service.
1 parent da22ac0 commit d37a49e

File tree

4 files changed

+84
-18
lines changed

4 files changed

+84
-18
lines changed

docs/en/stack/security/authentication/index.asciidoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
include::overview.asciidoc[]
44
include::built-in-users.asciidoc[]
55
include::internal-users.asciidoc[]
6+
include::token-authentication-services.asciidoc[]
67
include::realms.asciidoc[]
78
include::realm-chains.asciidoc[]
89
include::active-directory-realm.asciidoc[]

docs/en/stack/security/authentication/overview.asciidoc

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,22 @@ means (typically referred to as authentication tokens).
99
The {stack} authenticates users by identifying the users behind the requests
1010
that hit the cluster and verifying that they are who they claim to be. The
1111
authentication process is handled by one or more authentication services called
12-
<<realms,_realms_>>.
12+
<<realms,_realms_>>.
1313

1414
You can use the native support for managing and authenticating users, or
1515
integrate with external user management systems such as LDAP and Active
16-
Directory.
16+
Directory.
1717

18-
{security} provides built-in realms such as `native`,`ldap`, `active_directory`,
19-
`pki`, `file`, and `saml`. If none of the built-in realms meet your needs, you
20-
can also build your own custom realm and plug it into the {stack}.
18+
The {stack-security-features} provide built-in realms such as `native`,`ldap`,
19+
`active_directory`, `pki`, `file`, and `saml`. If none of the built-in realms
20+
meet your needs, you can also build your own custom realm and plug it in.
2121

2222
When {security-features} are enabled, depending on the realms you've configured,
2323
you must attach your user credentials to the requests sent to {es}. For example,
24-
when using realms that support usernames and passwords you can simply attach
24+
when using realms that support usernames and passwords you can simply attach
2525
{wikipedia}/Basic_access_authentication[basic auth] header to the requests.
26+
27+
The {security-features} provide two services: the token service and the api key
28+
service. You can use these services to exchange the current authentication for
29+
a token or key. This token or key can then be used as credentials for authenticating
30+
new requests. These services are enabled by default when TLS/SSL is enabled for HTTP.

docs/en/stack/security/authentication/realms.asciidoc

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,17 @@
22
[[realms]]
33
=== Realms
44

5-
Authentication in {security} is handled by one or more authentication services
6-
called _realms_. A _realm_ is used to resolve and authenticate users based on
7-
authentication tokens. {security} provides the following built-in realms:
5+
The {stack-security-features} authenticate users by using realms and one or more
6+
<<token-authentication-services,token-based authentication services>>.
7+
8+
A _realm_ is used to resolve and authenticate users based on authentication
9+
tokens. The {security-features} provide the following built-in realms:
810

911
_native_::
1012
An internal realm where users are stored in a dedicated {es} index.
1113
This realm supports an authentication token in the form of username and password,
1214
and is available by default when no realms are explicitly configured. The users
13-
are managed via the {ref}/security-api.html#security-user-apis[user management APIs].
15+
are managed via the {ref}/security-api.html#security-user-apis[user management APIs].
1416
See <<native-realm>>.
1517

1618
_ldap_::
@@ -43,23 +45,23 @@ _kerberos_::
4345
A realm that authenticates a user using Kerberos authentication. Users are
4446
authenticated on the basis of Kerberos tickets. See <<kerberos-realm>>.
4547

46-
{security} also supports custom realms. If you need to integrate with another
47-
authentication system, you can build a custom realm plugin. For more information,
48-
see <<custom-realms, Integrating with Other Authentication Systems>>.
48+
The {security-features} also support custom realms. If you need to integrate
49+
with another authentication system, you can build a custom realm plugin. For
50+
more information, see <<custom-realms>>.
4951

5052
==== Internal and external realms
5153

5254
Realm types can roughly be classified in two categories:
5355

5456
Internal:: Realms that are internal to Elasticsearch and don't require any
55-
communication with external parties. They are fully managed by
56-
{security}. There can only be a maximum of one configured realm
57-
per internal realm type. {security} provides two internal realm
57+
communication with external parties. They are fully managed by the
58+
{security-features}. There can only be a maximum of one configured
59+
realm per internal realm type. {security} provides two internal realm
5860
types: `native` and `file`.
5961

6062
External:: Realms that require interaction with parties/components external to
6163
{es}, typically, with enterprise grade identity management
6264
systems. Unlike internal realms, there can be as many external realms
6365
as one would like - each with its own unique name and configuration.
64-
{security} provides the following external realm types: `ldap`,
65-
`active_directory`, `saml`, `kerberos` and `pki`.
66+
The {security-features} provide the following external realm types:
67+
`ldap`, `active_directory`, `saml`, `kerberos` and `pki`.
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
[role="xpack"]
2+
[[token-authentication-services]]
3+
=== Token-based authentication services
4+
5+
The {stack-security-features} authenticate users by using realms and one or more token-based
6+
authentication services. The token-based authentication services are used for
7+
authentication and for the management of tokens. These tokens can be used as
8+
credentials attached to requests that are sent to {es}. When {es} receives a request
9+
that must be authenticated, it consults first the token-based authentication
10+
services then the realm chain.
11+
12+
The {security-features} provide the following built-in token-based authentication
13+
services, which are listed in the order they are consulted:
14+
15+
_token-service_::
16+
The token service uses the {ref}/security-api-get-token.html[get token API] to
17+
generate access tokens and refresh tokens based on the OAuth2 specification.
18+
The access token is a short-lived token. By default, it expires after 20 minutes
19+
but it can be configured to last a maximum of 1 hour. It can be refreshed by
20+
using a refresh token, which has a lifetime of 24 hours. The access token is a
21+
bearer token. You can use it by sending a request with an `Authorization`
22+
header with a value that has the prefix "Bearer " followed by the value of the
23+
access token. For example:
24+
+
25+
--
26+
[source,shell]
27+
--------------------------------------------------
28+
curl -H "Authorization: Bearer dGhpcyBpcyBub3QgYSByZWFsIHRva2VuIGJ1dCBpdCBpcyBvbmx5IHRlc3QgZGF0YS4gZG8gbm90IHRyeSB0byByZWFkIHRva2VuIQ==" http://localhost:9200/_cluster/health
29+
--------------------------------------------------
30+
// NOTCONSOLE
31+
--
32+
33+
_api-key-service_::
34+
The API key service uses the
35+
{ref}/security-api-create-api-key.html[create API key API] to generate API keys.
36+
By default, the API keys do not expire. When you make a request to create API
37+
keys, you can specify an expiration and permissions for the API key. The
38+
permissions are limited by the authenticated user's permissions. You can use the
39+
API key by sending a request with an `Authorization` header with a value that
40+
has the prefix "ApiKey " followed by the credentials. The credentials are the
41+
base64 encoding of the API key ID and the API key joined by a colon. For example:
42+
+
43+
--
44+
[source,shell]
45+
--------------------------------------------------
46+
curl -H "Authorization: ApiKey VnVhQ2ZHY0JDZGJrUW0tZTVhT3g6dWkybHAyYXhUTm1zeWFrdzl0dk5udw==" http://localhost:9200/_cluster/health
47+
--------------------------------------------------
48+
// NOTCONSOLE
49+
--
50+
51+
Depending on your use case, you may want to decide on the lifetime of the tokens
52+
generated by these services. You can then use this information to decide which
53+
service to use to generate and manage the tokens. Non-expiring API keys may seem
54+
like the easy option but you must consider the security implications that come
55+
with non-expiring keys. Both the _token-service_ and _api-key-service_ permit
56+
you to invalidate the tokens. See
57+
{ref}/security-api-invalidate-token.html[invalidate token API] and
58+
{ref}/security-api-invalidate-api-key.html[invalidate API key API].

0 commit comments

Comments
 (0)