fix(jwt): store raw JWT token in cookies without Bearer prefix#4552
fix(jwt): store raw JWT token in cookies without Bearer prefix#4552provinzkraut merged 6 commits intolitestar-org:mainfrom
Conversation
provinzkraut
left a comment
There was a problem hiding this comment.
This PR completely changes how the auth middleware works. While it might be questionable whether it should implicitly authenticate against a token found either in the header or the cookie, now it does not handle authentication headers at all anymore, which will break existing applications.
If you want to fix the cookie encoding, I suggest you keep the change at just that.
If you want to change where the token is read from, I suggest you make it configurable, and keep in mind that it should not break existing applications.
|
is it really expected behavior that the |
No, it doesn't. That's why I said it's questionable :) I just wanted to point out that, if this change is being made, it would need to be an intentional breaking change. That's a separate change from the one that this PR initially suggested to make:
Should be separate PRs IMO, the individual changes are fine. |
agreed |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4552 +/- ##
==========================================
- Coverage 97.85% 97.85% -0.01%
==========================================
Files 297 297
Lines 15336 15335 -1
Branches 1720 1720
==========================================
- Hits 15007 15006 -1
Misses 188 188
Partials 141 141 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
not sure why the |
nothing woring on your side there are issues reaching the alchemy docs |
|
Thanks @disrupted! |
* fix(jwt): store raw JWT token in cookies without Bearer prefix * fix(jwt): update OAuth2PasswordBearerAuth as well * fix(jwt): restore backwards compatibility * test(jwt): add assertion for correct cookie format * fix(jwt): parse correct and legacy token formats * docs: restore pydoc string (cherry picked from commit 594fb07)
Description
when switching to
JWTCookieAuthI noticed how it incorrectly stores the JWT token with a "Bearer " prefix in the cookie value.AFAICT this violates:
I also updated the middleware accordingly.
OAuth2PasswordBearerAuthwas also affected.Closes
Todo