Use new headers crate instead of hyper-old-types#158
Open
mthebridge wants to merge 3 commits intomasterfrom
Open
Use new headers crate instead of hyper-old-types#158mthebridge wants to merge 3 commits intomasterfrom
mthebridge wants to merge 3 commits intomasterfrom
Conversation
Signed-off-by: Mark Thebridge <mark.thebridge@metaswitch.com>
Signed-off-by: Mark Thebridge <mark.thebridge@metaswitch.com>
mthebridge
commented
Jul 20, 2022
src/auth.rs
Outdated
| password: Some(password.to_owned()), | ||
| }) | ||
| let basic = Header::basic(username, password); | ||
| AuthData::Basic(basic.username().to_owned(), basic.password().to_owned()) |
Contributor
Author
There was a problem hiding this comment.
I've just realised this is a pretty pointless implementation - I'm cnnstucting the header for no reason. I feel like ideally, we would return https://docs.rs/headers/latest/headers/authorization/struct.Basic.html here - but that has no constructor beyond a decode from a HeaderValue. (Same applies to the Bearer variant). We could make the inner type an authorization header but that feels wrong too.
Thoughts welcome!
Signed-off-by: Mark Thebridge <mark.thebridge@metaswitch.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Signed-off-by: Mark Thebridge mark.thebridge@metaswitch.com
hyper-old-typesis no longer maintained. Switch to theheadershyper crate instead - https://docs.rs/headers/latest/headers/authorization/index.htmlThis is a breaking change because
swagger-rsre-exported types.AuthDataenum variants just wrap Strings. This is slightly uglier, but the innerBasicandBearertypes inheaderscan't be directly constructed, only decoded from an Authorization header, and this felt like a more efficient implementation.from_headersmethod now returns anOption<AuthData>, thus removing any public authentication type reexports and avoiding exposing the whole swagger ecosystem to upstream breaking changes.There were no existing tests of
AuthData- not sure what would be useful to add, but will do if there's anything you think would help?