Authentication #164
Replies: 2 comments 5 replies
-
|
Hey @Tuntii. Any ideas? |
Beta Was this translation helpful? Give feedback.
-
|
Hi Peter! Sorry for the long delay, and thanks for your patience. I tracked this down, and the problem is most likely not your token generation or the The issue is the That means the middleware skips JWT validation for the protected routes as well, so no validated claims are inserted into the request. Then
Immediate fixPlease remove .layer(
JwtLayer::<Claims>::new(JWT_SECRET)
.skip_paths(vec!["/health", "/docs", "/auth/login"])
)After that, the protected routes should start receiving the authenticated claims correctly, assuming you are sending:
Why this was confusingThe error message makes it look like the middleware is missing, but in this case the middleware is present it is just skipping the protected route because of the root path entry. Maintainer-side follow-upI’ve also fixed this on the framework side so that So the short version is:
If you want, paste your middleware setup here and I can sanity-check it line by line. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello Tunay. I hope you're doing well.
It's so quiet here; I'll start a new discussion 😀
I've just implemented a basic authentication, following the example project under "https://github.com/Tuntii/RustAPI-examples/tree/main/auth-api".
Unfortunately, I keep getting the error:
{"error":{"type":"unauthorized","message":"No authenticated user. Did you forget to add JwtLayer middleware?"},"error_id":"err_3f3b5304cda046d18900fec6327bfa0d"}Any Ideas? Did I forget something?
You can test it with my code on codeberg under the branch "authentication"
Beta Was this translation helpful? Give feedback.
All reactions