Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
7fb6aec
feat(dpop): add dpop proof
OffRange Oct 20, 2026
266617f
feat(dpop): add basic dpop verification
OffRange Oct 20, 2026
9ebf669
feat(dpop): add jti ttl and seen checks
OffRange Oct 21, 2026
b5b072d
refactor(dpop): move to hashmap to drop moka
OffRange Oct 22, 2026
3ccc707
feat(api): add dpop crate
OffRange Oct 22, 2026
d063432
feat(opaque): add dpop binding
OffRange Oct 22, 2026
9c2ea30
feat(api): add dpop extractor
OffRange Oct 23, 2026
1dc989e
feat(api): bind login finish to dpop proof
OffRange Oct 24, 2026
c1c0deb
refactor(api): derive error status from code and slim down ServerError
OffRange Oct 24, 2026
5d6eb87
docs: drop internal spec section references from comments
OffRange Oct 24, 2026
4265767
feat(api): add device info
OffRange Oct 25, 2026
690439e
feat(tokens): add session tokens
OffRange Oct 27, 2026
1ae1200
feat(api): implement /auth/token endpoint
OffRange Oct 28, 2026
3584ce7
feat(api): implement authentication extractors
OffRange Oct 28, 2026
9ba0364
fix(dpop): keep unauthenticated proofs out of the replay store
OffRange Oct 29, 2026
d7512a4
feat(api): add Cache-Control: no-store
OffRange Oct 29, 2026
7b50da1
feat(db): index foreign keys
OffRange Oct 29, 2026
5d9bc3a
refactor(token): make private
OffRange Oct 29, 2026
7133b9f
refactor(session): drop magic numbers
OffRange Oct 29, 2026
53ce161
feat(api): answer with Retry-After when jti store is full
OffRange Oct 29, 2026
19a933d
refactor(dpop): drop nonce key secret
OffRange Oct 29, 2026
bc8551c
refactor(service): drop checkpoint in session issuing
OffRange Oct 29, 2026
3a101b0
refactor(db): dedup revoke reason extraction
OffRange Oct 29, 2026
2af6edf
refactor(db): reuse device service for registration finish
OffRange Oct 29, 2026
05a606c
chore(dpop): expect new_without_default on verifier
OffRange Oct 29, 2026
dbb952b
refactor(token): gate expose behind cfg(test)
OffRange Oct 29, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ tokio = "1.48.0"
uuid = { version = "1.23.1", features = ["serde", "v4"] }
uniffi = "0.32.0"
zeroize = "1.8.2"
base64 = "0.23.1"

[profile.release]
lto = true
Expand Down
2 changes: 1 addition & 1 deletion rust/crates/keygo-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ edition.workspace = true
thiserror.workspace = true
uuid.workspace = true
zeroize.workspace = true
base64.workspace = true

aead = "0.6.0"
aes-gcm-siv = "0.12.1"
Expand All @@ -19,7 +20,6 @@ passkey-authenticator = { version = "0.6.0", features = ["tokio"] }
passkey-types = { version = "0.6.0", features = ["serialize_bytes_as_base64_string"] }

argon2 = "0.6.0"
base64 = "0.23.1"
bcs = "0.2.0"
csv = "1.4.0"
email_address = "0.2.9"
Expand Down
21 changes: 21 additions & 0 deletions rust/crates/keygo-dpop/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[package]
name = "keygo-dpop"
version.workspace = true
edition.workspace = true

[features]
# Exposes `testing::TestSigner` so other crates' tests can sign proofs.
test-support = []

[dependencies]
thiserror.workspace = true
zeroize.workspace = true
base64.workspace = true

fluent-uri = "0.4.1"
hmac = "0.13.0"
p256 = { version = "0.14.0", default-features = false, features = ["ecdsa", "getrandom"] }
serde = { version = "1.0.229", features = ["derive"] }
serde_json = "1.0.154"
sha2 = "0.11.1"
getrandom = "0.4.3"
121 changes: 121 additions & 0 deletions rust/crates/keygo-dpop/src/htu.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
use fluent_uri::Uri;

/// Compares a proof's `htu` with the request URI as RFC 9449 §4.3 asks: ignoring query and fragment,
/// after RFC 3986 syntax-based (§6.2.2) and scheme-based (§6.2.3) normalization. Either side failing
/// to parse as an absolute URI is a mismatch.
pub(crate) fn matches(htu: &str, request: &str) -> bool {
match (canonical(htu), canonical(request)) {
(Some(htu), Some(request)) => htu == request,
_ => false,
}
}

/// The RFC 9449 §4.2 form of `uri`: normalized, without query and fragment. `None` unless `uri` is
/// absolute.
pub(crate) fn canonical(uri: &str) -> Option<String> {
let uri = Uri::parse(uri).ok()?.normalize();
let mut canonical = format!("{}:", uri.scheme().as_str());

if let Some(authority) = uri.authority() {
canonical.push_str("//");
canonical.push_str(authority.as_str());
}
match uri.path().as_str() {
// RFC 3986 §6.2.3: with an authority, an empty path means "/".
"" if uri.authority().is_some() => canonical.push('/'),
path => canonical.push_str(path),
}

Some(canonical)
}

#[cfg(test)]
mod tests {
use super::*;

const REQUEST: &str = "https://vault.example.org/v1/auth/token";

#[test]
fn identical_uris_match() {
assert!(matches(REQUEST, REQUEST));
}

#[test]
fn ignores_query_and_fragment() {
assert!(matches(
"https://vault.example.org/v1/auth/token?a=b#c",
REQUEST
));
assert!(matches(
REQUEST,
"https://vault.example.org/v1/auth/token?x=1"
));
}

#[test]
fn scheme_and_host_are_case_insensitive() {
assert!(matches("HTTPS://Vault.EXAMPLE.org/v1/auth/token", REQUEST));
}

#[test]
fn path_is_case_sensitive() {
assert!(!matches("https://vault.example.org/v1/Auth/token", REQUEST));
}

#[test]
fn default_port_is_dropped() {
assert!(matches(
"https://vault.example.org:443/v1/auth/token",
REQUEST
));
assert!(!matches(
"https://vault.example.org:8443/v1/auth/token",
REQUEST
));
}

#[test]
fn unreserved_percent_encoding_is_decoded() {
assert!(matches(
"https://vault.example.org/v1/%61uth/token",
REQUEST
));
}

#[test]
fn reserved_percent_encoding_is_kept() {
assert!(!matches(
"https://vault.example.org/v1%2Fauth/token",
REQUEST
));
}

#[test]
fn dot_segments_are_removed() {
assert!(matches(
"https://vault.example.org/v1/x/../auth/./token",
REQUEST
));
}

#[test]
fn empty_path_equals_root() {
assert!(matches(
"https://vault.example.org",
"https://vault.example.org/"
));
}

#[test]
fn other_scheme_or_host_does_not_match() {
assert!(!matches("http://vault.example.org/v1/auth/token", REQUEST));
assert!(!matches("https://evil.example.org/v1/auth/token", REQUEST));
}

#[test]
fn unparsable_uri_does_not_match() {
assert!(!matches("not a uri", REQUEST));
assert!(!matches("/v1/auth/token", REQUEST));
assert!(!matches(REQUEST, "not a uri"));
}
}
Loading
Loading