You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/security/how-clients-authenticate.adoc
+9-364Lines changed: 9 additions & 364 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,9 +19,7 @@ In this guide, you'll learn how to:
19
19
20
20
. Authenticate using Basic Authentication with username and password
21
21
. Understand how the Authorization header works
22
-
. Use authentication tokens for subsequent requests (password and client_credentials grant types)
23
-
. Auto-discover server metadata via the RFC 8414 discovery endpoint
24
-
. Manage authentication tokens (retrieve and invalidate)
22
+
. Obtain and use OAuth 2.0 access tokens
25
23
. Check user credentials and roles
26
24
. Avoid browser authentication popups
27
25
@@ -105,371 +103,18 @@ In other words:
105
103
106
104
=== Authentication Token
107
105
108
-
==== Modern OAuth 2.0 Token Endpoint (Recommended)
106
+
RESTHeart v9 provides a standards-compliant OAuth 2.0/2.1 token endpoint.
107
+
See the link:/docs/security/oauth[OAuth 2.0 / 2.1] page for full documentation on:
109
108
110
-
RESTHeart v9 introduces dedicated OAuth 2.0-compatible token endpoints for secure and standards-compliant authentication. This is the recommended approach for new applications.
111
-
112
-
**Available Endpoints:**
113
-
114
-
* `POST /token` - Returns JWT token in response body (supports `password` and `client_credentials` grant types)
115
-
* `POST /token/cookie` - Sets JWT token as HttpOnly cookie (enhanced security for browser-based apps)
116
-
* `GET /.well-known/oauth-authorization-server` - Returns server metadata for client auto-discovery (RFC 8414)
117
-
118
-
**Benefits:**
119
-
120
-
* 85% performance improvement over the legacy token injection approach
NOTE: `client_id` and `client_secret` are mapped to the user credentials in the configured authenticator (e.g., `mongoRealmAuthenticator`). The client account must exist in the user store just like a regular user account.
286
-
287
-
===== Using the Token
288
-
289
-
Once you have the token, use it as a Bearer token in the Authorization header:
NOTE: Generating a new token is a cryptographic operation and can have significant performance overhead. It is the responsibility of the client to renew the token using this query parameter when it is going to expire soon.
361
-
362
-
===== Cookie-Based Authentication
363
-
364
-
For browser-based applications, use the `/token/cookie` endpoint to set an HttpOnly cookie (more secure as the token isn't exposed to JavaScript):
365
-
366
-
==== cURL
367
-
[source,bash]
368
-
----
369
-
curl -i -X POST [RESTHEART-URL]/token/cookie \
370
-
-u [BASIC-AUTH] \
371
-
-c cookies.txt
372
-
----
373
-
374
-
==== HTTPie
375
-
[source,bash]
376
-
----
377
-
http --session=./session.json POST [RESTHEART-URL]/token/cookie \
NOTE: This is the legacy token management approach. For new applications, use the OAuth 2.0 `/token` endpoint described above.
117
+
NOTE: This is the legacy token management approach. For new applications, use the link:/docs/security/oauth[OAuth 2.0 `/token` endpoint].
473
118
474
119
RESTHeart can also automatically inject auth tokens into response headers. The default configuration includes the **tokenBasicAuthMechanism** and the **rndTokenManager**.
0 commit comments