-
Notifications
You must be signed in to change notification settings - Fork 8
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
Public Metadata Issuance #25
base: main
Are you sure you want to change the base?
Conversation
src/auth/authorize.rs
Outdated
let err = nom::Err::Failure(nom::error::make_error(input, nom::error::ErrorKind::Tag)); | ||
|
||
for (key, value) in key_values { | ||
match key.to_lowercase().as_str() { | ||
match dbg!(key).to_lowercase().as_str() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extra debug?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! I'm not very familiar with the issuance protocol, so I flagged @chris-wood for a review as well.
I commented on a few nits for now. I see this is written so that the existing API isn't touched much. I wouldn't be against bringing the two variants of public tokens closer together on the API level. This isn't even published as a crate yet, so we still have full flexibility.
) -> Result<(Token<Nk>, Option<Vec<u8>>), ParseError> { | ||
let s = value.to_str().map_err(|_| ParseError::InvalidInput)?; | ||
let mut tokens = parse_header_value(s)?; | ||
Ok(tokens.pop().unwrap()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should return an error instead
Ok(token) | ||
} | ||
|
||
/// Parses an `Authorization` header according to the following scheme: | ||
/// | ||
/// `PrivateToken token=... [extensions=...]` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// `PrivateToken token=... [extensions=...]` | |
/// `PrivateToken token=... [, extensions=...]` |
src/auth/authorize.rs
Outdated
@@ -148,6 +148,30 @@ pub fn build_authorization_header<Nk: ArrayLength<u8>>( | |||
Ok((header_name, header_value)) | |||
} | |||
|
|||
/// Builds a `Authorize` header according to the following scheme: | |||
/// | |||
/// `PrivateToken token=...,extensions=...` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// `PrivateToken token=...,extensions=...` | |
/// `PrivateToken token=..., extensions=...` |
src/auth/authorize.rs
Outdated
extensions: &[u8], | ||
) -> Result<(HeaderName, HeaderValue), BuildError> { | ||
let value = format!( | ||
"PrivateToken token={},extensions={}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"PrivateToken token={},extensions={}", | |
"PrivateToken token={}, extensions={}", |
Extensions may be used in new Privacy Pass issuance protocols to encode additional information alongside a token.
This is a variant of the Privacy Pass issuance protocol that encodes public information that is cryptographically bound to the token but visible to all parties (i.e. the metadata is cleartext). A new API for issuing public tokens has been created which is extensible in terms of the issuance protocol the client wishes to use. The basic Privacy Pass issuance protocol is implemented in terms of this generic implementation. https://datatracker.ietf.org/doc/html/draft-hendrickson-privacypass-public-metadata
a92d382
to
52b4970
Compare
* delimit kvs with a ` ` rather than `,`. * values can be optionally surrounded with quotes * quirk: allow for URL_SAFE and URL_SAFE_NO_PAD encoding for extension values
Update to the newest revision and allow for some quirks
This is a variant of the Privacy Pass issuance protocol that encodes
public information that is cryptographically bound to the token but
visible to all parties (i.e. the metadata is cleartext).
The Authorisation header can receive this metadata via the extensions parameter alongside the existing token param.
A new API for issuing public tokens has been created which is extensible
in terms of the issuance protocol the client wishes to use. The basic
Privacy Pass issuance protocol is implemented in terms of this generic
implementation.
https://datatracker.ietf.org/doc/html/draft-hendrickson-privacypass-public-metadata
cc @chris-wood