Expand description
Authorization, Proxy-Authorization, WWW-Authenticate, and
Proxy-Authenticate (RFC 9110 section 11), with the Bearer (RFC 6750)
and Basic (RFC 7617) payloads.
Credentials are secrets: Debug on Credentials and AuthPayload
prints the scheme and parameter names only.
§Examples
use parse_net::{self as pn, auth, Limits};
assert_eq!(pn::bearer(b"bearer mF_9.B5f-4.1JqM==")?, Some(&b"mF_9.B5f-4.1JqM=="[..]));
assert_eq!(pn::bearer(b"Basic dXNlcjpwYXNz")?, None);
assert_eq!(pn::basic(b"Basic dXNlcjpwYXNz")?, Some(&b"dXNlcjpwYXNz"[..]));
let c = auth::parse_credentials(b"Digest username=\"a\", realm=\"r\"", &Limits::DEFAULT)?;
assert!(c.scheme_is("digest"));
assert_eq!(format!("{c:?}"), "Credentials { scheme: \"Digest\", .. }");Structs§
- Auth
Params - Comma-separated
auth-params, validated. - Challenge
- One challenge.
- Challenge
Iter - The challenges of a validated value.
- Challenges
- Validated challenges.
- Credentials
- Validated credentials (
Authorization,Proxy-Authorization).
Enums§
- Auth
Payload - What follows the scheme of a credential or a challenge.
Functions§
- basic
- The base64 text of a
BasicAuthorizationvalue (RFC 7617):Somewhen the scheme isBasic,Nonefor another scheme. The text is checked (the base64 alphabet, padding only at the end, a length that is a multiple of four) and not decoded. - bearer
- The
Bearertoken of anAuthorizationvalue (RFC 6750 section 2.1):Some(token)when the scheme isBearer(case-insensitive),Nonefor another scheme. - parse_
challenges - Parses
WWW-AuthenticateorProxy-Authenticate:#challenge. - parse_
credentials - Parses
credentials = auth-scheme [ 1*SP ( token68 / #auth-param ) ]. - write_
challenge - Writes a challenge with parameters:
Bearer realm="api", error="invalid_token".realmis always quoted (RFC 9110 section 11.5); other values are tokens when they can be. - write_
challenge_ token68 - Writes a challenge with a
token68:Negotiate <token68>.