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
{{ message }}
Repository navigation
Commit eec2e5b
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: src/Adapters/Auth/keycloak.js
+25-2Lines changed: 25 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -7,6 +7,7 @@
7
7
* @param {String} options.config.auth-server-url - The Keycloak authentication server URL.
8
8
* @param {String} options.config.realm - The Keycloak realm name.
9
9
* @param {String} options.config.client-id - The Keycloak client ID.
10
+
* @param {String|String[]} [options.audience] - The expected access token audience (optional). If set, an access token whose `aud` claim contains none of these values is rejected.
10
11
*
11
12
* @param {Object} authData - The authentication data provided by the client.
12
13
* @param {String} authData.access_token - The Keycloak access token retrieved during client authentication.
@@ -51,8 +52,21 @@
51
52
* }
52
53
* ```
53
54
*
55
+
* ## Audience Validation
56
+
* Keycloak does not add the client that a token is issued to into the access token audience by default, so Parse Server validates the `aud` claim only if `audience` is set. To use it, add an audience mapper in Keycloak so that the access tokens for Parse Server contain the configured value:
57
+
* ```javascript
58
+
* {
59
+
* "auth": {
60
+
* "keycloak": {
61
+
* "config": require('./auth/keycloak.json'),
62
+
* "audience": "parse-server"
63
+
* }
64
+
* }
65
+
* }
66
+
* ```
67
+
*
54
68
* ## Notes
55
-
* - Parse Server validates the provided `authData` by making a `userinfo` call to Keycloak and ensures the attributes match those returned by Keycloak.
69
+
* - Parse Server verifies the access token locally with the public keys of the realm. The token must be issued by the realm (`iss`), to the configured `client-id` (`azp`), and for the user `id` (`sub`). The `roles` and `groups` in the auth data must equal the `roles` and `groups` claims of the token.
56
70
*
57
71
* ## Keycloak Configuration
58
72
* To configure Keycloak, copy the JSON configuration file generated from Keycloak's setup guide:
@@ -64,6 +78,7 @@
64
78
* For more information on Keycloak authentication, see:
0 commit comments