Replies: 2 comments 1 reply
-
Hi, You are right, these fields should be public in order to allow custom implementations of middleware. Historically the bearer token support was not there. But you are right that for a bearer token, especially like JWT tokens, it would need to be decoded and parsed in the middleware to extract its content, or, validated against an external system. I have sent a PR here to fix all that: #309 With this PR you have the ability to create your own middleware like you did and access the fields now, or use like in the Auth example the provided one and add a callback (easier). You can try the branch:
|
Beta Was this translation helpful? Give feedback.
-
Wow that was an impressively fast turn around, well done! I'll give this a whirl tomorrow and get back to you if I've any issues, but by the looks of it, you've hit everything I was looking for. My session manager is basic at the moment (just randomly generated tokens and a table to match tokens with users) but I want to experiment with JWT as that is obviously superior (as long as the signing process can be hardware accelerated). If I get something tidy together I'll share it so that you can update your auth example. Cheers! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi Team - I'm delighted this project is up and running again! I'm currently refactoring one of my bigger projects to make use of the new features. I'm currently investigating the various authorization middlewares which is a fantastic addition. I have a question about how you intended bearer token authorization to work.
I see that in
AsyncWebServerRequest::_parseReqHeader()
that_authMethod
should hold the auth method and_authorization
should hold the token if the correct header is present. It would be convenient if something like this were possible in my custom middleware:However, since both
_authMethod
and_authorization
are private inAsyncWebServerRequest
and there donβt appear to be any public getters, Iβm wondering:Did you have another intended way for middleware to access the bearer token or auth method?
Beta Was this translation helpful? Give feedback.
All reactions