Skip to content

providers/oauth2: allow cross-provider token introspection#19867

Open
harryyoud wants to merge 1 commit intogoauthentik:mainfrom
harryyoud:feature/oauth2-introspect-other-providers
Open

providers/oauth2: allow cross-provider token introspection#19867
harryyoud wants to merge 1 commit intogoauthentik:mainfrom
harryyoud:feature/oauth2-introspect-other-providers

Conversation

@harryyoud
Copy link

Details

closes #11597
closes #11618

Since #11537, you can no longer introspect tokens created by another provider. This creates problems when using one OAuth2 provider to authenticate to an API protected by another provider.

My example is Stalwart mail server (which supports OAuth2 authentication), with Roundcube mail server. Currently, I have to use the userinfo endpoint, which is no longer recommended because Stalwart cannot check the audience of the token (see https://www.reddit.com/r/stalwartlabs/comments/1q8otw8/comment/nzfigmr/).

With this patch, you can now allow other providers tokens to be used at the introspection endpoint on a whitelist basis. This is in keeping with the security patch for #11537, but allows the flexibility of cross-provider token introspection.


Checklist

  • Local tests pass (ak test authentik/)
  • The code has been formatted (make lint-fix)

If an API change has been made

  • The API schema has been updated (make gen-build)

If changes to the frontend have been made

  • The code has been formatted (make web)

If applicable

  • The documentation has been updated
  • The documentation has been formatted (make docs)

@harryyoud harryyoud requested review from a team as code owners January 29, 2026 23:12
@netlify
Copy link

netlify bot commented Jan 29, 2026

Deploy Preview for authentik-integrations ready!

Name Link
🔨 Latest commit 2b2d235
🔍 Latest deploy log https://app.netlify.com/projects/authentik-integrations/deploys/697be95c2776240007374d92
😎 Deploy Preview https://deploy-preview-19867--authentik-integrations.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link

netlify bot commented Jan 29, 2026

Deploy Preview for authentik-storybook ready!

Name Link
🔨 Latest commit 2b2d235
🔍 Latest deploy log https://app.netlify.com/projects/authentik-storybook/deploys/697be95c3237bd00083c97d2
😎 Deploy Preview https://deploy-preview-19867--authentik-storybook.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

refresh_token = RefreshToken.objects.filter(token=raw_token, provider__in=providers).first()
if refresh_token:
return TokenIntrospectionParams(refresh_token, provider)
return TokenIntrospectionParams(refresh_token, refresh_token.provider)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please may I have some advice on whether we should be returning the authenticated provider or the original token's provider in the introspection response - this only influences the client_id part of the token JSON response

if access_token:
return TokenIntrospectionParams(access_token, provider)
refresh_token = RefreshToken.objects.filter(token=raw_token, provider=provider).first()
return TokenIntrospectionParams(access_token, access_token.provider)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here also, see comment below

@netlify
Copy link

netlify bot commented Jan 29, 2026

Deploy Preview for authentik-docs ready!

Name Link
🔨 Latest commit 2b2d235
🔍 Latest deploy log https://app.netlify.com/projects/authentik-docs/deploys/697be95c391c7800088545a2
😎 Deploy Preview https://deploy-preview-19867--authentik-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@harryyoud
Copy link
Author

Tested; working well for me. I've published a testing server docker image at https://github.com/harryyoud/authentik/pkgs/container/authentik with these changes.

@harryyoud
Copy link
Author

@BeryJu are you happy to review this since you commented: #11597 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow cross provider oauth2 token introspection and restrict to confidential clients Cross OAuth2 provider token introspection not directly possible

1 participant