-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
question: authorization, typed headers and hyper types #1150
Comments
The response side is pretty easy to deal with - all of the reexported header types implement On the request side, I unfortunately don't see an obvious way to parse headers aside from hyper's parse_header function which would require you to copy the header data a time or two. It's worth mentioning that typed headers might be removed or replaced with a different implementation in 0.5 (see #1067), in which case you will need to do manual parsing or adapt to a different typed header library. |
Thanks @jebrosen |
@jebrosen reopening, as Im having trouble actually using that parse_header thing. the Header trait that defines parse_header doesnt seem to be publicly re-exported
Would adding |
That would re-export it, but I'm not too happy about the idea of reexporting even more from hyper. You can add |
Will do, thanks! |
Most everything seems pretty strongly typed in rocket, but I found myself having to write a lot more string related code than I was expecting to do something as simple request guard for http basic-auth.
Is there a plan for something like being able to get typed header data out of the request/put it into the response? something like:
let a: Result<Authorization,Error> = request.header::<Authorization>()
as part of going from
request.headers().get_one("Authorization")
to something typed that I can use in a guard, I also dipped into the 'vendored' hyper classes since that does have the notion of typed headers including Authorization with Basic and Bearer schemes. Some of the docs seem to warn against using the hyper types, is there an alternative Ive missed?Questions
Any questions must include:
0.4.2
Reading Docs and Code and Issues
some docs on how to implement authn/z in rocket.
The text was updated successfully, but these errors were encountered: