How automatic scope filtering works
mainThe middleware includes an automatic scope filtering mechanism to prevent authentication failures caused by requesting unsupported scopes.
The Process
- The middleware fetches the provider's
.well-known/openid-configuration. - It extracts the
scopes_supportedfield from the discovery document. - It compares your requested
scopesagainst the supported list. - It filters out any requested scopes that the provider does not support.
- If the provider does not declare supported scopes, the middleware falls back to using all requested scopes.
Example: Self-Hosted GitLab
If you request offline_access but GitLab's discovery document does not list it in scopes_supported, the middleware will automatically remove it before sending the request, allowing authentication to succeed.
Troubleshooting Scope Issues
If a provider still rejects scopes after filtering:
- Verify the provider's capabilities by running:
curl https://provider/.well-known/openid-configuration. - Use the
overrideScopes: trueoption and provide only the scopes known to be supported. - Check the middleware logs for
ScopeFilterentries to see which scopes were removed.