Cookie jar (from axum-extra) not passed from one middleware to another? #2754
Replies: 2 comments 1 reply
-
When I print the cookie jar in the
I tried using |
Beta Was this translation helpful? Give feedback.
-
Your middleware is adding the modified I think for your use case, |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
I want to setup a scheme where the first time a client connects it gets a cookie with an id. The first client id to connect needs to be considered "admin". Subsequent client connections provides the client id and certain routes are nested under an admin group and must be served only to the admin.
Right now I have something like that:
The middleware signatures are as follow:
I'm using
CookieJar
fromaxum-extra
0.9.3.So I expect the
create_client_id_if_absent()
middleware to run first and for all routes. This would create the client it if not present. Then only/admin
routes check the validity of the client id.This kind of work but not completely. Looking at logs for a client connecting to the admin route, I see that the
create_client_id_if_absent()
middleware is first called, which is good. Then, theadmin_middleware()
is called, which is also good. But the cookie jar in theadmin_middleware()
is empty, even though I return the jar in the first middleware.What am I doing wrong?
Thanks!!
axum version
0.7.5
Beta Was this translation helpful? Give feedback.
All reactions