Repository navigation
flows: keep ?next url when using cancel - #18619
Conversation
Signed-off-by: Jens Langhammer <[email protected]>
✅ Deploy Preview for authentik-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for authentik-storybook canceled.
|
✅ Deploy Preview for authentik-integrations canceled.
|
| 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
Show autofix suggestion
Hide autofix suggestion
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:
- Import
url_has_allowed_host_and_schemefromdjango.utils.http. - In the affected snippet (within
CancelView.get), replace the check usingis_url_absolute(next_url)with a call tourl_has_allowed_host_and_scheme(next_url, allowed_hosts). For maximum safety, useNoneasallowed_hosts(checks against the current host) or restrict to known host(s). - The redirect should only occur if the validation passes; otherwise, redirect to a safe default.
What to change:
- The code region in
CancelView.getmethod (lines 477–486), notably the check and redirect at lines 482–484. - Add the necessary import.
- Remove or update any dependence on
is_url_absoluteas appropriate for this block.
| @@ -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") | ||
|
|
Codecov Report❌ Patch coverage is
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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
|
authentik PR Installation instructions Instructions for docker-composeAdd the following block to your 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)sAfterwards, run the upgrade commands from the latest release notes. Instructions for KubernetesAdd the following block to your 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-9ee8d53487c5cc05c3fce3a826100f1ab5793b7fAfterwards, run the upgrade commands from the latest release notes. |
* 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) ...
closes #14671
closes #12223