How do I create a middleware that can read cookie #3024
Unanswered
finlaydotb
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am setting data in a httpOnly cookie, this means that the javascript cannot directly interact with it, but on each request it is sent to the backend.
The content of the cookie is used for authorization purposes. Now I can include logic in every handler to extract the content of the cookie but I thought that will be tedious.
So I was thinking to extract the logic to get the cookie value and perform the authorization logic in a middleware. But unfortunately I have not been able to find out.
The closes I found is based off using
actix_session
but that does not fit my bill because it will still involve injectingSession
into every handler, and then perform the authorization checks. I'll the handlers don't contain this logic and hence why i will love to put it in a middleware.Any ideas on how to go about this?
Beta Was this translation helpful? Give feedback.
All reactions