Repository navigation
flows: fix flow executor authentication with jwt - #16646
Conversation
✅ Deploy Preview for authentik-docs canceled.
|
✅ Deploy Preview for authentik-storybook ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for authentik-integrations canceled.
|
ac784cc to
377e77c
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #16646 +/- ##
==========================================
+ Coverage 93.09% 93.22% +0.13%
==========================================
Files 1038 1038
Lines 60744 60777 +33
Branches 400 400
==========================================
+ Hits 56549 56659 +110
+ Misses 4195 4118 -77
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
3fbd5ab to
65801b0
Compare
65801b0 to
788f26e
Compare
|
I rebased the branch on the current main branch. |
|
So far, I have not noticed interest by the authentik team. Can I have a signal from the team if it is worth to rebase this (again)? |
788f26e to
5e2f6b3
Compare
With this commit, we move the session authentication logic from
the dispatch() method to perform_authentication() method, which
is now also overridden from the APIView parent class.
The major difference here is the order in which things are called
now.
The most important point is that the django request object is
wrapped by the django rest framework in APIView.dispatch() by
calling APIView.initialize_request(). This method returns a
wrapped version of the request (of type rest_framework.Request).
This wrapper class implicitly performs the authentication
from the authentication_classes, when request.user is accessed.
Before this commit, the original django request object
was passed to FlowPlanner._check_authentication() before
it was wrapped into a rest_framework.Request, which led
to the authentication_classes not been recognized.
The call chain was:
FlowExecutorView.dispatch()
FlowExecutorView._initiate_plan()
FlowPlanner.plan()
FlowPlanner._check_authentication()
APIView.dispatch()
APIView.initialize_request()
With this commit, the flow session logic is moved to
FlowExecutorView.perform_authentication() such that
the wrapped request instance is properly passed down
to FlowPlanner._check_authentication()
The new call chain is then:
FlowExecutorView.dispatch()
APIView.dispatch()
APIView.initialize_request()
APIView.initial()
FlowExecutorView.perform_authentication()
FlowExecutorView._initiate_plan()
FlowPlanner.plan()
FlowPlanner._check_authentication()
Since we can not return HttpResponses from
FlowExecutorView.perform_authentication() some exception
handlers remain in the dispatch() method. Additionally,
two new exceptions are introduced which are raised
in perform_authentication() and caught in dispatch() to
be transformed into HttpResponses.
Fixes goauthentik#15747
We can use handle_exception() instead...
5e2f6b3 to
af8f4c2
Compare
|
Seems like a long backlog 🥲 |
|
@rissson 2026.2.1 is released, this one is stuck on 2025.12.4 milestone. Will this ever get merged? |
|
@BeryJu is looking into this and will feedback |
|
Hi again. Can we provide any help to bring this forward. :)? |
Signed-off-by: Jens Langhammer <[email protected]> # Conflicts: # authentik/flows/tests/test_executor.py
Signed-off-by: Jens Langhammer <[email protected]>
Signed-off-by: Jens Langhammer <[email protected]>
BeryJu
left a comment
There was a problem hiding this comment.
Sorry it took so long to get around to this, I rewrote the PR a bit to minimise the changes but kept the test the same
Signed-off-by: Jens Langhammer <[email protected]>
Signed-off-by: Jens Langhammer <[email protected]>
|
I'd now suggest to revert #15252, since this is no longer true with this being merged. |
…yers' into web/css/enabling-layers * refs/remotes/origin/web/css/enabling-layers: (23 commits) flows: fix flow executor authentication with jwt (#16646) web: bump playwright from 1.60.0 to 1.61.0 in /web (#23542) core, web: update translations (#23534) web: bump the eslint group across 1 directory with 3 updates (#23538) web: bump type-fest from 5.6.0 to 5.7.0 in /web (#23544) lifecycle/aws: bump aws-cdk from 2.1128.0 to 2.1128.1 in /lifecycle/aws (#23535) core: bump deepmerge from 2.0 to 2.1.0 (#23539) root: fix "make gen" failing with "the input device is not a TTY" (#23546) core: bump library/golang from `76a2924` to `68b7145` in /lifecycle/container (#23536) core: bump goauthentik/fips-python from `15f00f3` to `6067443` in /lifecycle/container (#23537) website/integrations: fix logo missing (#23548) translate: Updates for project authentik and language ar_AA (#23516) Web/maintenance/explicit model endpoints (#22897) providers/oauth: Properly return error via post and for request objects (#23037) providers/oauth: Logout remove static html (#23002) core: bump dramatiq from 2.1.0 to 2.2.0 (#23381) website: bump semver from 7.8.4 to 7.8.5 in /website (#23299) web/flows: fix untranslated user field labels in identification stage (#23518) tasks/schedules: fix paused schedules getting unpaused on startup (#23521) sources/ldap: avoid re-creating connections to LDAP server (#23520) ...
* main: (415 commits) Web/maintenance: Replace routine form endpoints (#23554) root: move server and worker healthcheck to rust (#23556) website/docs: api: remove note (#23555) web: bump @playwright/test from 1.60.0 to 1.61.0 in /web (#23545) providers/scim: fix enum warning when de-serializing (#23553) flows: fix flow executor authentication with jwt (#16646) web: bump playwright from 1.60.0 to 1.61.0 in /web (#23542) core, web: update translations (#23534) web: bump the eslint group across 1 directory with 3 updates (#23538) web: bump type-fest from 5.6.0 to 5.7.0 in /web (#23544) lifecycle/aws: bump aws-cdk from 2.1128.0 to 2.1128.1 in /lifecycle/aws (#23535) core: bump deepmerge from 2.0 to 2.1.0 (#23539) root: fix "make gen" failing with "the input device is not a TTY" (#23546) core: bump library/golang from `76a2924` to `68b7145` in /lifecycle/container (#23536) core: bump goauthentik/fips-python from `15f00f3` to `6067443` in /lifecycle/container (#23537) website/integrations: fix logo missing (#23548) translate: Updates for project authentik and language ar_AA (#23516) Web/maintenance/explicit model endpoints (#22897) providers/oauth: Properly return error via post and for request objects (#23037) providers/oauth: Logout remove static html (#23002) ...
* main: (487 commits) Web/maintenance: Replace routine form endpoints (#23554) root: move server and worker healthcheck to rust (#23556) website/docs: api: remove note (#23555) web: bump @playwright/test from 1.60.0 to 1.61.0 in /web (#23545) providers/scim: fix enum warning when de-serializing (#23553) flows: fix flow executor authentication with jwt (#16646) web: bump playwright from 1.60.0 to 1.61.0 in /web (#23542) core, web: update translations (#23534) web: bump the eslint group across 1 directory with 3 updates (#23538) web: bump type-fest from 5.6.0 to 5.7.0 in /web (#23544) lifecycle/aws: bump aws-cdk from 2.1128.0 to 2.1128.1 in /lifecycle/aws (#23535) core: bump deepmerge from 2.0 to 2.1.0 (#23539) root: fix "make gen" failing with "the input device is not a TTY" (#23546) core: bump library/golang from `76a2924` to `68b7145` in /lifecycle/container (#23536) core: bump goauthentik/fips-python from `15f00f3` to `6067443` in /lifecycle/container (#23537) website/integrations: fix logo missing (#23548) translate: Updates for project authentik and language ar_AA (#23516) Web/maintenance/explicit model endpoints (#22897) providers/oauth: Properly return error via post and for request objects (#23037) providers/oauth: Logout remove static html (#23002) ...
* main: Web/maintenance: Replace routine form endpoints (#23554) root: move server and worker healthcheck to rust (#23556) website/docs: api: remove note (#23555) web: bump @playwright/test from 1.60.0 to 1.61.0 in /web (#23545) providers/scim: fix enum warning when de-serializing (#23553) flows: fix flow executor authentication with jwt (#16646) web: bump playwright from 1.60.0 to 1.61.0 in /web (#23542) core, web: update translations (#23534) web: bump the eslint group across 1 directory with 3 updates (#23538) web: bump type-fest from 5.6.0 to 5.7.0 in /web (#23544) lifecycle/aws: bump aws-cdk from 2.1128.0 to 2.1128.1 in /lifecycle/aws (#23535) core: bump deepmerge from 2.0 to 2.1.0 (#23539) root: fix "make gen" failing with "the input device is not a TTY" (#23546) core: bump library/golang from `76a2924` to `68b7145` in /lifecycle/container (#23536) core: bump goauthentik/fips-python from `15f00f3` to `6067443` in /lifecycle/container (#23537) website/integrations: fix logo missing (#23548) translate: Updates for project authentik and language ar_AA (#23516) Web/maintenance/explicit model endpoints (#22897) providers/oauth: Properly return error via post and for request objects (#23037) providers/oauth: Logout remove static html (#23002)
Details
As described in issue #15747, the authentication with a JWT for the flow executor was broken. This PR fixes that. Furthermore, a unit test is added that catches this error.
I am happy to receive some feedback from the authentik devs. This mostly a proof of concept to show a way how this issue COULD be solved. If another solution is preferred, we could also go for that.
Checklist
ak test authentik/)make lint-fix)closes #15747