core: allow creating tokens for other user without superuser - #16224
core: allow creating tokens for other user without superuser#16224BeryJu wants to merge 2 commits into
Conversation
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
✅ Deploy Preview for authentik-storybook canceled.
|
✅ Deploy Preview for authentik-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for authentik-integrations canceled.
|
❌ 12 Tests Failed:
View the top 3 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
|
We might want to add a few tests for this. |
✅ Deploy Preview for authentik-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
gergosimonyi
left a comment
There was a problem hiding this comment.
This is very suspicious. It feels like change_user shouldn't ever be enough to create a token that lets me do anything in that user's name.
I believe a larger restructure is needed. This shouldn't just be blanket bearer token. Instead, it should carry the information that "I am a token User A created to (in effect) impersonate User B". Then the backend could have some say in whether it wants to allow that.
| if not request.user.has_perm("change_user", user) and not request.user.has_perm( | ||
| "authentik_core.change_user" | ||
| ): |
There was a problem hiding this comment.
No need to check separately, has_perm checks both.
| if not request.user.has_perm("change_user", user) and not request.user.has_perm( | |
| "authentik_core.change_user" | |
| ): | |
| if not request.user.has_perm("authentik_core.change_user", user): |
| if not request.user.has_perm("change_user", user) and not request.user.has_perm( | ||
| "authentik_core.change_user" | ||
| ): | ||
| raise ValidationError("Cannot create token for this user") |
There was a problem hiding this comment.
Errors like this should not be raised in validate_* functions, but earlier in the process.
Details
REPLACE ME
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 docs)