Skip to content

How do you get access to the cache from an JWTAuthenticationMiddleware? #1337

Answered by provinzkraut
danechitoaie asked this question in Q&A
Discussion options

You must be logged in to vote

but the authenticate_request of JWTAuthenticationMiddleware does not have a scope param?

scope is an attribute of ASGIConnection, which is passed into authenticate_request.
So you could access the scope like this: connection.scope, and get the cache with connection.scope["app"].cache.

You don't need to go through so many indirections though, as ASGIConenction directly exposes app and cache properties, which means the easiest way to access it is connection.cache.

Check out the ASGIConnection docs.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by danechitoaie
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants