@@ -151,22 +151,70 @@ payload to be useful.
151151}
152152```
153153
154- ### OpenID Connect
154+ ## OpenID Connect
155155
156- MaxScale implements a limited set of OpenID Connect compatible endpoints and
157- supports the use of the Implicit Flow for authentication of REST-API
158- clients. These endpoints are intended to be used when MaxScale is configured
159- with ` admin_oidc_url ` that points to another MaxScale to whom the authentication
160- and authorization is delegated to. The only workflow from OpenID Connect that
161- MaxScale implements and uses is the Implicit Flow which returns tokens in the
162- redirection URL.
156+ MaxScale implements support for OpenID Connect for authentication of REST-API
157+ clients. MaxScale implements both the Code Flow and the Implicit Flows from
158+ OpenID Connect.
163159
164- Other OpenID Connect providers that implement the Implict Flow can be
165- used with MaxScale to implement SSO for the REST-API and the MaxScale
166- GUI .
160+ The OpenID Connect server is defined using the ` admin_oidc_url ` setting and the
161+ credentials used to access it are defined using ` admin_oidc_client_id ` and
162+ ` admin_oidc_client_secret ` .
167163
168164MaxScale uses the ` admin_jwt_issuer ` as the ` client_id ` in all OpenID Connect
169- requests.
165+ requests unless ` admin_oidc_client_id ` has been defined.
166+
167+ The ` account ` and ` permissions ` values of the generated JWT for the REST-API
168+ client are extracted from the ID token and access tokens that are sent at the
169+ end of the OpenID Connect authentication process and the contents of the
170+ userinfo endpoint that's accessed using the access token.
171+
172+ To define the permissions of an externally authenticated user, the OpenID
173+ Connect identity provider must be able to define custom claims in the JWT. The
174+ exact method of doing this depends on the identity provider.
175+
176+ If the ` permissions ` field is present and it is an array of strings that defines
177+ at least one valid [ API permission] ( maxscale-role-resource.md#create-a-role ) ,
178+ the values are expected to be the permissions of the user and they are used
179+ directly. If the ` permissions ` field is not present but the ` account ` field is,
180+ it is expected to be the name of a [ role] ( maxscale-role-resource.md ) which is
181+ then used to authorize the user.
182+
183+ For example, with the following JWT payload, the permissions of the user are
184+ read from the ` permissions ` field, which in this case are ` edit ` and ` view ` , and
185+ the account name is taken from the ` account ` field. The account in this case is
186+ only used for display purposes and if it's missing, the value ` external ` is used
187+ instead.
188+
189+ ``` javascript
190+ {
191+ " account" : " manager" ,
192+ " permissions" : [
193+ " edit" ,
194+ " view"
195+ ],
196+ " aud" : " maxscale" ,
197+ " exp" : 1753487037 ,
198+ " iat" : 1753458237 ,
199+ " iss" : " www.mariadb.com" ,
200+ " sub" : " foo"
201+ }
202+ ```
203+
204+ Whereas with the following JWT payload, the permissions of the user are from the
205+ ` admin ` role so changes to the role in MaxScale itself are reflected instantly
206+ in the user's permissions.
207+
208+ ``` javascript
209+ {
210+ " account" : " admin" ,
211+ " aud" : " maxscale" ,
212+ " exp" : 1753487037 ,
213+ " iat" : 1753458237 ,
214+ " iss" : " www.mariadb.com" ,
215+ " sub" : " foo"
216+ }
217+ ```
170218
171219#### ` /login `
172220
@@ -192,22 +240,17 @@ whether the `/login` and `/logout` endpoints cause a redirect, i.e. whether
192240
193241#### ` /authorize `
194242
195- The ` /authorize ` endpoint implements the OAuth 2 endpoint for
196- authorization. MaxScale does not implement the token endpoint as it only
197- supports Implicit Flow authentication and thus all responses will contain the
198- id_token value.
199-
200- The only suppored ` scope ` value is ` open_id ` and the ` response_type ` must be
201- ` id_token ` . If a ` nonce ` value is provided, it is added to the generated JWT
202- under the ` nonce ` claim.
243+ The ` /authorize ` endpoint implements the OAuth 2 endpoint for authorization.
203244
204- In the redirect response, ` id_token ` contains the generated JWT and ` token_type `
205- is always set to ` bearer. The ` expires_in` value contains the lifetime of the
206- generated JWT. If a ` state ` value was given , it is included in the redirect
207- response .
245+ The ` scope ` must contain the value ` open_id ` and the ` response_type ` must be
246+ either ` id_token ` for the Implicit Flow or ` code ` for the Code Flow. If a
247+ ` nonce ` value is provided , it is added to the generated JWT under the ` nonce `
248+ claim .
208249
209- Any tokens generated from the ` /authorize ` endpoint will have their lifetime set
210- to 8 hours or the value of ` admin_jwt_max_age ` if it is lower than 8 hours.
250+ In the redirect response for the Implicit Flow, ` id_token ` contains the
251+ generated JWT and ` token_type ` is always set to ` bearer. The ` expires_in` value
252+ contains the lifetime of the generated JWT. If a ` state ` value was given, it is
253+ included in the redirect response.
211254
212255#### ` /jwks `
213256
0 commit comments