events: fix incorrect user logged when using API token authentication#9302
events: fix incorrect user logged when using API token authentication#9302
Conversation
✅ Deploy Preview for authentik-docs canceled.
|
✅ Deploy Preview for authentik-storybook canceled.
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #9302 +/- ##
=======================================
Coverage 92.38% 92.39%
=======================================
Files 665 665
Lines 32609 32617 +8
=======================================
+ Hits 30126 30135 +9
+ Misses 2483 2482 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
b5e750a to
6368390
Compare
kensternberg-authentik
left a comment
There was a problem hiding this comment.
At a syntactical level, this doesn't look like brain science.
|
authentik PR Installation instructions Instructions for docker-composeAdd the following block to your AUTHENTIK_IMAGE=ghcr.io/goauthentik/dev-server
AUTHENTIK_TAG=gh-ghcr.io/goauthentik/dev-server:gh-6368390aab65e4f061590838b7feb44e7f94eb5c
AUTHENTIK_OUTPOSTS__CONTAINER_IMAGE_BASE=ghcr.io/goauthentik/dev-%(type)s:gh-%(build_hash)sFor arm64, use these values: AUTHENTIK_IMAGE=ghcr.io/goauthentik/dev-server
AUTHENTIK_TAG=gh-ghcr.io/goauthentik/dev-server:gh-6368390aab65e4f061590838b7feb44e7f94eb5c-arm64
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
image:
repository: ghcr.io/goauthentik/dev-server
tag: gh-ghcr.io/goauthentik/dev-server:gh-6368390aab65e4f061590838b7feb44e7f94eb5cFor arm64, use these values: authentik:
outposts:
container_image_base: ghcr.io/goauthentik/dev-%(type)s:gh-%(build_hash)s
image:
repository: ghcr.io/goauthentik/dev-server
tag: gh-ghcr.io/goauthentik/dev-server:gh-6368390aab65e4f061590838b7feb44e7f94eb5c-arm64Afterwards, run the upgrade commands from the latest release notes. |
|
/cherry-pick version-2024.2 |
|
Cherry-pick failed with |
…#9302) Signed-off-by: Jens Langhammer <jens@goauthentik.io> # Conflicts: # authentik/events/middleware.py # authentik/events/tests/test_middleware.py
* main: (23 commits) web: bump API Client version (#9316) release: 2024.2.3 website/docs: 2024.2.3 release notes (#9313) web/admin: fix log viewer empty state (#9315) website/docs: fix formatting for stage changes (#9314) core: bump github.com/go-ldap/ldap/v3 from 3.4.7 to 3.4.8 (#9310) core: bump goauthentik.io/api/v3 from 3.2024022.11 to 3.2024022.12 (#9311) web: bump core-js from 3.36.1 to 3.37.0 in /web (#9309) core: bump gunicorn from 21.2.0 to 22.0.0 (#9308) core, web: update translations (#9307) website/docs: system settings: add default token duration and length (#9306) web/flows: update flow background (#9305) web: fix locale loading being skipped (#9301) translate: Updates for file web/xliff/en.xlf in fr (#9304) translate: Updates for file locale/en/LC_MESSAGES/django.po in fr (#9303) core: replace authentik_signals_ignored_fields with audit_ignore (#9291) web/flow: fix form input rendering issue (#9297) events: fix incorrect user logged when using API token authentication (#9302) translate: Updates for file locale/en/LC_MESSAGES/django.po in zh_CN (#9293) translate: Updates for file locale/en/LC_MESSAGES/django.po in zh-Hans (#9295) ...
Details
This was introduced in 2024.2 by incorrectly caching the user from before the request instead of taking it from the request when an action was actually done. This works fine with the session auth as the session middleware happens before the event middleware, however since the token authentication modifies the user as part of the view and not the middleware, the user was updated too late.
This also adds a test that makes sure this doesn't happen again.
Checklist
ak test authentik/)make lint-fix)If an API change has been made
make gen-build)If changes to the frontend have been made
make web)If applicable
make website)