Repository navigation
feat(oidc): SessionKey::derive from a generated secret - #191
Merged
Merged
Conversation
SessionKey::from_bytes takes 32 raw bytes, but a deployment's secret store usually holds a generated string (ADR-style "generated secrets"), so every host hashes it into a key on its own. derive does it once: HKDF-SHA256 over the secret, with a context that says what the key is for, so one secret used for two purposes gives two unrelated keys. A secret shorter than 32 bytes is refused with OidcConfigError::ShortSessionSecret, which names the length, never the bytes. A known-answer test pins the derivation: changing it would sign every session of every deployment out. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
aroff
enabled auto-merge (squash)
October 17, 2026 20:36
Keeps it apart from the host-session list's other new bullet, so the two PRs merge in either order. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
SessionKey::derive(secret: &[u8], context: &[u8]) -> Result<SessionKey, OidcConfigError>andSessionKey::MIN_SECRET_LEN(32).SessionKey::from_bytestakes 32 raw bytes. A deployment's secret store usually holds a generated string instead, so every host turns that string into a key on its own.derivedoes it in one place:info=context, 32 bytes out (RFC 5869);OidcConfigError::ShortSessionSecret(len). The enum is#[non_exhaustive], so the new variant is not a breaking change.The first user is Pauta (rudaia-hq/pauta). Its instance keeps the page's session secret in a generated Secret. It keeps a small local SHA-256 stopgap until this lands, then moves to
derive.What could leak, and which test shows it does not
derive_refuses_a_short_secret_without_naming_it(a canary in the short secret is absent from the message)infoderive_depends_on_both_the_secret_and_the_contextderive_gives_hkdf_sha256_of_the_secret_for_the_contextThe derived bytes are zeroized after they are copied into the key.
SessionKeykeeps noDebug.Checks
cargo fmt --all -- --checkcargo clippy --all-features -- -D warningscargo test -p cli-framework-oidcwith featuresbrowser(52 passed),host-session,test-support(169 passed),client,server(92 passed),server,test-support(109 passed)🤖 Generated with Claude Code