http-rs / http-types

Common types for HTTP operations
https://docs.rs/http-types
Apache License 2.0
200 stars 83 forks source link

Add `auth::{Authorization, AuthenticationScheme, BasicAuth, WwwAuthenticate, ProxyAuthorization, ProxyAuthenticate}` #252

Closed yoshuawuyts closed 3 years ago

yoshuawuyts commented 4 years ago

Ref #99

Adds HTTP basic auth and related structs for authentication.

BasicAuth is a specialization of Authorization; because schemes like oauth are rather elaborate, we've chosen to put them into separate structs.

Thanks!

Screenshots

Screenshot_2020-10-01 http_types auth - Rust

yoshuawuyts commented 4 years ago

I've added support for WWW-Authenticate, but need to change it up slightly before merging. Right now we support at most 1 authentication scheme, but the spec says this should be up to n. Also since Proxy-Authenticate parses exactly the same way as WWW-Authenticate we can copy-paste the impl once it works. That should provide the majority of common authentication things.

yoshuawuyts commented 3 years ago

Okay; all implemented!

Fishrock123 commented 3 years ago

BasicAuth seems to work fine, as I am using it here: https://github.com/squamishaccess/squamishaccess-signup-function-rs/blob/6c445916760a4db21da80c732fbe8e9c704c1bd1/src/main.rs#L168-L172

However I did run into a UX issue with typed headers and surf: https://github.com/http-rs/surf/issues/251