Skip to content
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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

cbranch
Copy link
Contributor

@cbranch cbranch commented Nov 16, 2023

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

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() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extra debug?

Copy link
Owner

@raphaelrobert raphaelrobert left a 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())
Copy link
Owner

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=...]`
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// `PrivateToken token=... [extensions=...]`
/// `PrivateToken token=... [, extensions=...]`

@@ -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=...`
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// `PrivateToken token=...,extensions=...`
/// `PrivateToken token=..., extensions=...`

extensions: &[u8],
) -> Result<(HeaderName, HeaderValue), BuildError> {
let value = format!(
"PrivateToken token={},extensions={}",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"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
@cbranch cbranch force-pushed the cbranch/public-metadata branch from a92d382 to 52b4970 Compare December 4, 2023 16:03
fisherdarling and others added 2 commits December 19, 2023 18:33
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants