Skip to content

flows: keep ?next url when using cancel - #18619

Merged
BeryJu merged 1 commit into
mainfrom
flows/cancel-keep-next-url
Dec 5, 2025
Merged

BeryJu merged 1 commit into
mainfrom
flows/cancel-keep-next-url

Conversation

@BeryJu

@BeryJu BeryJu commented Dec 4, 2025

Copy link
Copy Markdown
Member

closes #14671
closes #12223

Signed-off-by: Jens Langhammer <[email protected]>
@BeryJu
BeryJu requested a review from a team as a code owner December 4, 2025 22:06
@netlify

netlify Bot commented Dec 4, 2025 •

Copy link
Copy Markdown

✅ Deploy Preview for authentik-docs ready!

Name Link
🔨 Latest commit 9ee8d53
🔍 Latest deploy log https://app.netlify.com/projects/authentik-docs/deploys/693205d65a47fe00084575c5
😎 Deploy Preview https://deploy-preview-18619--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 Dec 4, 2025 •

Copy link
Copy Markdown

✅ Deploy Preview for authentik-storybook canceled.

Name Link
🔨 Latest commit 9ee8d53
🔍 Latest deploy log https://app.netlify.com/projects/authentik-storybook/deploys/693205d6bbfe1100085cb145

@netlify

netlify Bot commented Dec 4, 2025 •

Copy link
Copy Markdown

✅ Deploy Preview for authentik-integrations canceled.

Name Link
🔨 Latest commit 9ee8d53
🔍 Latest deploy log https://app.netlify.com/projects/authentik-integrations/deploys/693205d6165cb00008ec3252

LOGGER.debug("Canceled current plan")
next_url = self.request.GET.get(NEXT_ARG_NAME)
if next_url and not is_url_absolute(next_url):
return redirect(next_url)

Check warning

Code scanning / CodeQL

URL redirection from remote source

Untrusted URL redirection depends on a [user-provided value](1).

Copilot Autofix

AI 12 months ago

To fix the open redirect vulnerability, we should validate the user-provided URL before redirection using Django's built-in url_has_allowed_host_and_scheme function.

Steps:

  1. Import url_has_allowed_host_and_scheme from django.utils.http.
  2. In the affected snippet (within CancelView.get), replace the check using is_url_absolute(next_url) with a call to url_has_allowed_host_and_scheme(next_url, allowed_hosts). For maximum safety, use None as allowed_hosts (checks against the current host) or restrict to known host(s).
  3. The redirect should only occur if the validation passes; otherwise, redirect to a safe default.

What to change:

  • The code region in CancelView.get method (lines 477–486), notably the check and redirect at lines 482–484.
  • Add the necessary import.
  • Remove or update any dependence on is_url_absolute as appropriate for this block.

Suggested changeset 1
authentik/flows/views/executor.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/authentik/flows/views/executor.py b/authentik/flows/views/executor.py
--- a/authentik/flows/views/executor.py
+++ b/authentik/flows/views/executor.py
@@ -8,6 +8,7 @@
 from django.http import Http404, HttpRequest, HttpResponse, HttpResponseRedirect
 from django.http.request import QueryDict
 from django.shortcuts import get_object_or_404, redirect
+from django.utils.http import url_has_allowed_host_and_scheme
 from django.template.response import TemplateResponse
 from django.urls import reverse
 from django.utils.decorators import method_decorator
@@ -480,7 +481,7 @@
             del request.session[SESSION_KEY_PLAN]
             LOGGER.debug("Canceled current plan")
         next_url = self.request.GET.get(NEXT_ARG_NAME)
-        if next_url and not is_url_absolute(next_url):
+        if next_url and url_has_allowed_host_and_scheme(next_url, allowed_hosts=None):
             return redirect(next_url)
         return redirect("authentik_flows:default-invalidation")
 
EOF
@@ -8,6 +8,7 @@
from django.http import Http404, HttpRequest, HttpResponse, HttpResponseRedirect
from django.http.request import QueryDict
from django.shortcuts import get_object_or_404, redirect
from django.utils.http import url_has_allowed_host_and_scheme
from django.template.response import TemplateResponse
from django.urls import reverse
from django.utils.decorators import method_decorator
@@ -480,7 +481,7 @@
del request.session[SESSION_KEY_PLAN]
LOGGER.debug("Canceled current plan")
next_url = self.request.GET.get(NEXT_ARG_NAME)
if next_url and not is_url_absolute(next_url):
if next_url and url_has_allowed_host_and_scheme(next_url, allowed_hosts=None):
return redirect(next_url)
return redirect("authentik_flows:default-invalidation")

Copilot is powered by AI and may make mistakes. Always verify output.
@codecov

codecov Bot commented Dec 4, 2025 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.50000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.19%. Comparing base (a42fc4b) to head (9ee8d53).
⚠️ Report is 31 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
authentik/flows/views/executor.py 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #18619      +/-   ##
==========================================
- Coverage   93.24%   93.19%   -0.05%     
==========================================
  Files         933      933              
  Lines       51164    51188      +24     
==========================================
- Hits        47707    47704       -3     
- Misses       3457     3484      +27     
Flag Coverage Δ
e2e 44.74% <37.50%> (-0.01%) ⬇️
integration 22.71% <12.50%> (-0.06%) ⬇️
unit 91.46% <87.50%> (+<0.01%) ⬆️
unit-migrate 91.51% <87.50%> (+<0.01%) ⬆️

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 Dec 4, 2025

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-9ee8d53487c5cc05c3fce3a826100f1ab5793b7f
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-9ee8d53487c5cc05c3fce3a826100f1ab5793b7f

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

@github-project-automation github-project-automation Bot moved this from Todo to In Progress in authentik Core Dec 5, 2025
@rissson rissson moved this from In Progress to In review in authentik Core Dec 5, 2025
@rissson rissson added this to the Release 2025.12 milestone Dec 5, 2025
@BeryJu
BeryJu merged commit 024e6c1 into main Dec 5, 2025
@BeryJu
BeryJu deleted the flows/cancel-keep-next-url branch December 5, 2025 14:35
@github-project-automation github-project-automation Bot moved this from In review to Done in authentik Core Dec 5, 2025
kensternberg-authentik added a commit that referenced this pull request Dec 11, 2025
* main: (40 commits)
  enterprise/stages/mtls: fix traefik certificate parsing (#18607)
  wed/admin: change s to S in "Stage" (#18632)
  flows: refresh unauthenticated tabs (#18621)
  flows: keep ?next url when using cancel (#18619)
  core, web: update translations (#18620)
  ci: bump actions/setup-node from 6.0.0 to 6.1.0 (#18552)
  core: bump goauthentik/fips-debian from `cf233be` to `a80dbbd` (#18594)
  web: bump @sentry/browser from 10.28.0 to 10.29.0 in /web in the sentry group across 1 directory (#18623)
  website/docs: adds note about ak_create_jwt function (#18614)
  api: fix IPC auth (#18612)
  web: bump mermaid from 11.12.1 to 11.12.2 in /web (#18602)
  web: Codemirror fixes (#18610)
  web: bump packages in /web (#18604)
  website/docs: expressions: fix markdown (#18613)
  website/docs: add missing API sidebar entry (#18586)
  web: bump yaml from 2.8.1 to 2.8.2 in /web (#18605)
  web/elements: update AppIcon story with files change (#18608)
  api: test action decorator (#18583)
  crypto: separate permissions for certificate and private keydownload (#18588)
  core: bump github.com/spf13/cobra from 1.10.1 to 1.10.2 (#18592)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Bug Report: "Not you?" Button Cancels Current Authentication Flow should we redirect to the next instead of root once we cancel the current flow

3 participants