authentik icon indicating copy to clipboard operation
authentik copied to clipboard

.well-known/openid-configuration is overly permissive with the scopes it publishes

Open markchalloner opened this issue 9 months ago • 5 comments

Describe the bug

.well-known/openid-configuration currently publishes all scopes, rather than those only required to auth.

Compare with Google:

 "scopes_supported": [
  "openid",
  "email",
  "profile"
 ],

and Microsoft:

  "scopes_supported": [
    "openid",
    "profile",
    "email",
    "offline_access"
  ],

How to reproduce

  1. Go to any instance of authentik: https:///.well-known/openid-configuration
  2. Verify scopes_supported list includes all scopes

Expected behavior

Only scopes required to auth listed.

Screenshots

No response

Additional context

No response

Deployment Method

Kubernetes

Version

2025.12.3

Relevant log output


markchalloner avatar Feb 25 '26 17:02 markchalloner

Not so much as a bug, rather a design choice. To give a counter-argument to hiding all available scopes except e.g. "openid" and "email", I have a SaaS that will only use the scopes it sees in the metadata. If it isn't in the metadata, the SaaS UI will not let me use the scope despite it being available. There is no UI for "typing in" a scope name, only for selecting from the list of scopes the SaaS discovered via metadata.

Ideally, we should be able to select not just which scopes are "available in Authentik >> selected for the specific Provider", but also the next step of "selected for the Provider >> exposed in Metadata". Here's a mockup:

Image

But this might as well be an overkill. Alternatively, "hide from metadata" can be a property of a custom scope (mapping).

headlesssetup avatar Feb 25 '26 18:02 headlesssetup

I don't neccessarily think it being a issue advertising more than needed for the auth. As per RFC8414 it should just advertise the scopes the server supports - not what is needed as a minimum for auth:

scopes_supported
      RECOMMENDED.  JSON array containing a list of the OAuth 2.0
      [[RFC6749](https://datatracker.ietf.org/doc/html/rfc6749)] "scope"
      values that this authorization server supports.
      Servers MAY choose not to advertise some supported scope values
      even when this parameter is used.

However a bit odd, that it also claims that servers "may choose not to advertise" scopes even though being supported...

patschi avatar Feb 26 '26 11:02 patschi

This is an intentional design decision specifically for applications like @headlesssetup mentioned, which just pick scopes from the discovery document and dont have an option to let you type in a scope name.

BeryJu avatar Feb 26 '26 12:02 BeryJu

a bit odd, that it also claims that servers "may choose not to advertise" scopes

Like the issue author stated, a server can expose custom per-client scopes, which impacts security (albeit slightly, since obscurity is not a good security measure), or there could be auto-generated scopes - thousands of them - and this is where signal turns to noise, making the metadata unnecessarily bloated.

Another gapstop option to solve the original issue is to allow admins to manually edit the metadata. E.g.: metadata is generated from settings -> edited by hand to remove sensitive parts at editor's risk -> stays like that despite config changes -> can be switched back to auto and regenerated.

headlesssetup avatar Feb 26 '26 12:02 headlesssetup

rather unlikely that we'll implement something like that. An option for configuring which of the configured scopes are advertised is more likely but not high on our priority list

BeryJu avatar Feb 26 '26 18:02 BeryJu