Skip to content

providers/oauth: post_logout_redirect_uri support - #20011

Merged
PeshekDotDev merged 19 commits into
mainfrom
oidc-logout-current
Apr 7, 2026
Merged

PeshekDotDev merged 19 commits into
mainfrom
oidc-logout-current

Conversation

@PeshekDotDev

@PeshekDotDev PeshekDotDev commented Feb 4, 2026 •

Copy link
Copy Markdown
Contributor

Details

This adds proper support for post_logout_redirect_uri with oidc logouts while largely improving the way we interact with RP's during rp-initiated logout. With this, we will:

Validate the post_logout_redirect_uri
Send a logout notification back to the rp via frontchannel or backchannel if properly configured on the provider
Delete the access token for the provider
Redirect you to the post_logout_redirect_uri location

closes #10430
closes #19201
ref #11710


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)

@PeshekDotDev PeshekDotDev self-assigned this Feb 4, 2026
@PeshekDotDev
PeshekDotDev requested a review from a team as a code owner February 4, 2026 09:33
@PeshekDotDev
PeshekDotDev requested a review from a team as a code owner February 4, 2026 09:33
@netlify

netlify Bot commented Feb 4, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for authentik-storybook ready!

Name Link
🔨 Latest commit 5da66d8
🔍 Latest deploy log https://app.netlify.com/projects/authentik-storybook/deploys/69d3f2ceea88f70008ec4fad
😎 Deploy Preview https://deploy-preview-20011--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.

@netlify

netlify Bot commented Feb 4, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for authentik-docs ready!

Name Link
🔨 Latest commit 5da66d8
🔍 Latest deploy log https://app.netlify.com/projects/authentik-docs/deploys/69d3f2ce4daa670008f13466
😎 Deploy Preview https://deploy-preview-20011--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.

@netlify

netlify Bot commented Feb 4, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for authentik-integrations ready!

Name Link
🔨 Latest commit 5da66d8
🔍 Latest deploy log https://app.netlify.com/projects/authentik-integrations/deploys/69d3f2ceea88f70008ec4fb1
😎 Deploy Preview https://deploy-preview-20011--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.

@codecov

codecov Bot commented Feb 4, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 84.65909% with 27 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.64%. Comparing base (5e33093) to head (5da66d8).
⚠️ Report is 4 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
authentik/providers/oauth2/utils.py 13.33% 13 Missing ⚠️
authentik/providers/oauth2/views/end_session.py 84.61% 8 Missing ⚠️
authentik/providers/oauth2/signals.py 33.33% 4 Missing ⚠️
authentik/flows/stage.py 60.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #20011      +/-   ##
==========================================
- Coverage   93.66%   92.64%   -1.03%     
==========================================
  Files        1001     1017      +16     
  Lines       56884    58527    +1643     
  Branches        0     1494    +1494     
==========================================
+ Hits        53282    54221     +939     
- Misses       3602     4266     +664     
- Partials        0       40      +40     
Flag Coverage Δ
conformance 37.01% <18.75%> (-0.06%) ⬇️
e2e 42.92% <28.97%> (-0.05%) ⬇️
integration 33.93% <16.47%> (-0.06%) ⬇️
rust 53.54% <ø> (?)
unit 91.89% <83.52%> (+0.01%) ⬆️
unit-migrate 91.96% <83.52%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@github-actions

github-actions Bot commented Feb 4, 2026 •

Copy link
Copy Markdown
Contributor

authentik PR Installation instructions

Instructions for docker-compose

Add the following block to your .env file:

AUTHENTIK_IMAGE=ghcr.io/goauthentik/dev-server
AUTHENTIK_TAG=gh-5da66d8ed05c74c0d3dd7ba425dd10aaeb4f164d
AUTHENTIK_OUTPOSTS__CONTAINER_IMAGE_BASE=ghcr.io/goauthentik/dev-%(type)s:gh-%(build_hash)s

Afterwards, run the upgrade commands from the latest release notes.

Instructions for Kubernetes

Add the following block to your values.yml file:

authentik:
    outposts:
        container_image_base: ghcr.io/goauthentik/dev-%(type)s:gh-%(build_hash)s
global:
    image:
        repository: ghcr.io/goauthentik/dev-server
        tag: gh-5da66d8ed05c74c0d3dd7ba425dd10aaeb4f164d

Afterwards, run the upgrade commands from the latest release notes.

@PeshekDotDev PeshekDotDev moved this from Todo to Needs review in authentik Core Feb 5, 2026
@BeryJu BeryJu changed the title OIDC post_logout_redirect_uri support providers/oauth: post_logout_redirect_uri support Feb 5, 2026
Comment thread authentik/providers/oauth2/models.py Resolved
Comment thread authentik/providers/oauth2/models.py Resolved
Comment thread authentik/providers/oauth2/signals.py Resolved
Comment thread authentik/providers/oauth2/utils.py Resolved
@PeshekDotDev PeshekDotDev moved this from Needs review to In review in authentik Core Feb 6, 2026
Comment thread authentik/providers/oauth2/signals.py Resolved
@mohammad-rj

Copy link
Copy Markdown

We've been struggling with this for a while — post_logout_redirect_uri was completely ignored after RP-Initiated Logout, causing Authentik to fall back to the default authentication flow instead of redirecting back to the application.

After applying this patch via volume mount on 2026.2.0, the full logout flow finally works as expected:

  1. User logs out of Gitea
  2. nginx relays to Authentik's end-session endpoint with post_logout_redirect_uri
  3. Authentik clears the session (UserLogoutStage) and redirects back to Gitea's login page
  4. Next login requires full re-authentication — no silent auto-approve

One thing worth noting: the patch introduces RedirectURIType.LOGOUT to distinguish logout redirect URIs from authorization ones. Existing redirect_uris entries default to authorization type, so any post_logout_redirect_uri you want to allow must be explicitly set to logout type. This isn't documented anywhere yet — would be good to call it out in the release notes or admin UI.

Thanks for pushing this forward. This is a real gap that affects anyone using RP-Initiated Logout with OIDC clients.

@BeryJu BeryJu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Some nits for imo cleaner import flow but lgtm

Comment thread authentik/flows/stage.py Outdated
)
from authentik.lib.avatars import DEFAULT_AVATAR, get_avatar
from authentik.lib.utils.reflection import class_to_path
from authentik.providers.oauth2.models import AccessToken, OAuth2Provider

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ideally "core" apps like flows shouldn't import statically from "modular" apps like the oauth2 provider

Comment thread authentik/flows/planner.py Outdated
PLAN_CONTEXT_IS_REDIRECTED = "is_redirected"
PLAN_CONTEXT_REDIRECT_STAGE_TARGET = "redirect_stage_target"
# OIDC RP-Initiated Logout context keys
PLAN_CONTEXT_POST_LOGOUT_REDIRECT_URI = "goauthentik.io/providers/oauth2/post_logout_redirect_uri"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@github-project-automation github-project-automation Bot moved this from In review to In Progress in authentik Core Mar 30, 2026
@PeshekDotDev
PeshekDotDev merged commit 8c3d5f1 into main Apr 7, 2026
156 of 160 checks passed
@PeshekDotDev
PeshekDotDev deleted the oidc-logout-current branch April 7, 2026 08:46
@github-project-automation github-project-automation Bot moved this from In Progress to Done in authentik Core Apr 7, 2026
davepgreene pushed a commit to davepgreene/authentik that referenced this pull request Apr 13, 2026
* oauth2/providers: add post logout redirect uri to providers

* properly handle post_logout_redirect_uri and frontchannel message to rp

* add backchannel support

* move logout url logic

* hanlde forbidden_uri_schemes on post_logout_redirect_uri

* merge post_logout with redirect_uri

---------

Signed-off-by: Connor Peshek <[email protected]>
Co-authored-by: Jens L. <[email protected]>
davepgreene pushed a commit to davepgreene/authentik that referenced this pull request Apr 13, 2026
* oauth2/providers: add post logout redirect uri to providers

* properly handle post_logout_redirect_uri and frontchannel message to rp

* add backchannel support

* move logout url logic

* hanlde forbidden_uri_schemes on post_logout_redirect_uri

* merge post_logout with redirect_uri

---------

Signed-off-by: Connor Peshek <[email protected]>
Co-authored-by: Jens L. <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

OIDC RP-Initiated Logout endpoint Broken Setting next or post_logout_redirect_uri properly?

3 participants