The purpose of OAuth 2.0 scopes is to limit the access rights granted to an OAuth client through an access token.
The following diagram should explain, how an authorization server decides what scopes to present to a user for consent:
- The AS supports the following sources for scopes:
- The client requests a set of scopes when starting an authorization code flow or grant.
- In the static client configuration of the AS, a list of Allowed/Default Scopes can be configured. In combination with the Filter Requested Scopes property, this is either interpreted as a filter against client-requested scopes or a default value to override client-supplied scopes.
- During registration using DCR a set of scopes can be registered and stored with the client.
- In the static client configuration of the AS or in the authorization code flow/grant, a list of Always Granted Scopes can be configured. This list is not affected by AS policies or filtering or user local consent choices
- The AS can be configured with
- a policy that decides how the different sources for scopes are processed.
- a filtering configuration that is applied to the selected source of scopes.
- In the local consent step of the authentication flow, the user will be presented with a form that
- presents the user with a list of all the scopes the AS has been configured to accept from the different sources after applying policies and filters.
- requires the user to decide whether a scope is granted or denied.
- persists the user's decision regarding the scopes.
- will only be shown again, if there is at least one scope that has not been decided (this may be a new scope or a scope that has been deleted by an administrator).
- will never ask the user for consent on Always Granted Scopes.
- During the final processing of the authorization code flow/grant, the following steps are executed:
- the list of Always Granted Scopes is added to the user-consented scopes.
- Claims are generated and Claim Conditions are applied
- the Granted Scope Processors configuration is applied to generate the scope claim
- access, ID, and refresh tokens are issued.