Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
4636a1d
feat(auth): establish service foundation
PiquelChips Jul 14, 2026
5bfe685
fix(auth): make foundation boundaries executable and fail closed
PiquelChips Jul 14, 2026
e77eeab
fix(ci): pin the declared Rust toolchain
PiquelChips Jul 14, 2026
9e19a39
feat(auth): add identity and session schema
PiquelChips Jul 14, 2026
10ce3b6
fix(auth): implement transactional identity repositories
PiquelChips Jul 14, 2026
5c16fcc
fix(auth): make account disablement a session invariant
PiquelChips Jul 14, 2026
ac051cf
feat(auth): add passkey ceremony foundation
PiquelChips Jul 14, 2026
76e3c70
fix(auth): implement verified passkey ceremonies
PiquelChips Jul 14, 2026
d7fa9b1
fix(auth): close passkey lifecycle races and add enrollment
PiquelChips Jul 14, 2026
0ab0e41
feat(auth): add oidc token lifecycle primitives
PiquelChips Jul 14, 2026
3613145
fix(auth): implement OIDC and rotating token lifecycle
PiquelChips Jul 14, 2026
b1bf5b0
fix(auth): complete authorization and refresh policy flows
PiquelChips Jul 14, 2026
2a6e6e5
Merge branch 'main' into auth/01-identity-sessions
PiquelChips Jul 14, 2026
96ef472
fix justfile merge
PiquelChips Jul 14, 2026
5b12045
fix merge
PiquelChips Jul 14, 2026
77a3534
fix docs comment
PiquelChips Jul 14, 2026
d168a77
Harden identity session and email ownership checks
PiquelChips Jul 14, 2026
3fb07c0
Merge branch 'auth/01-identity-sessions' into auth/02-passkeys
PiquelChips Jul 14, 2026
4f28f1e
fix database error
PiquelChips Jul 14, 2026
2b2b121
Merge branch 'main' into auth/02-passkeys
PiquelChips Jul 14, 2026
56b3677
fix merge
PiquelChips Jul 14, 2026
5f91493
add validate to justfile
PiquelChips Jul 14, 2026
c560b55
remove test-database
PiquelChips Jul 14, 2026
78b6e1e
Support bootstrap and enrollment passkeys
PiquelChips Jul 14, 2026
d38fbdb
Add purpose tokens for passkey management
PiquelChips Jul 15, 2026
83e0c86
Merge branch 'auth/02-passkeys' into auth/03-oidc-token-lifecycle
PiquelChips Jul 15, 2026
ea898c8
Merge remote-tracking branch 'origin/main' into auth/03-oidc-token-li…
PiquelChips Jul 15, 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
1 change: 1 addition & 0 deletions Cargo.lock

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

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,14 @@ axum = "0.8"
base64 = "0.22"
chrono = { version = "0.4", default-features = false, features = ["clock", "serde"] }
http = "1.3"
hmac = "0.12"
http-body-util = "0.1"
openssl = { version = "0.10", features = ["vendored"] }
p256 = { version = "0.13", features = ["ecdsa", "pem", "pkcs8"] }
rand = "0.8"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
sha2 = "0.10"
rand = "0.8"
sqlx = { version = "0.8", default-features = false, features = ["runtime-tokio-rustls", "postgres", "chrono", "uuid", "json", "migrate", "macros"] }
thiserror = "2.0"
tokio = { version = "1.48", features = ["macros", "rt-multi-thread", "signal", "net", "time"] }
Expand Down
3 changes: 2 additions & 1 deletion apps/auth-service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@ async-trait.workspace = true
axum.workspace = true
base64.workspace = true
chrono.workspace = true
hmac.workspace = true
openssl.workspace = true
p256.workspace = true
rand.workspace = true
serde.workspace = true
serde_json.workspace = true
thiserror.workspace = true
sha2.workspace = true
thiserror.workspace = true
tokio.workspace = true
tracing.workspace = true
unicode-normalization.workspace = true
Expand Down
1 change: 1 addition & 0 deletions apps/auth-service/src/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ pub(super) async fn disable(database: &Database, user_id: UserId) -> Result<bool
return Ok(false);
}
transaction.sessions().revoke_all_for_user(user_id).await?;
transaction.tokens().revoke_all_for_user(user_id).await?;
transaction
.audit_events()
.append(&AppendAuditEvent {
Expand Down
24 changes: 17 additions & 7 deletions apps/auth-service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ mod audit;
mod email;
#[allow(dead_code)]
mod event_log;
#[allow(dead_code)]
mod oidc;
pub use oidc::OidcApplication;
#[allow(dead_code)]
mod passkey;
pub use passkey::PasskeyApplication;
#[allow(dead_code)]
Expand All @@ -37,6 +41,8 @@ pub struct AuthConfig {
pub key_provider: SecretReference,
/// `WebAuthn` relying-party identifier.
pub webauthn_rp_id: String,
/// Enables loopback-only development relaxations.
pub development_mode: bool,
/// Stable identifier embedded in signed-token headers.
pub signing_key_id: String,
}
Expand Down Expand Up @@ -76,6 +82,7 @@ impl AuthConfig {
database,
key_provider: SecretReference::parse(&required("AUTH_KEY_PROVIDER")?)?,
webauthn_rp_id: required("AUTH_WEBAUTHN_RP_ID")?,
development_mode: development,
signing_key_id: required("AUTH_SIGNING_KEY_ID")?,
})
}
Expand Down Expand Up @@ -121,16 +128,19 @@ struct AppState {
}

/// Builds the public health-only router. Liveness has no dependencies; readiness fails closed.
pub fn router(readiness: Arc<dyn Readiness>, passkeys: Option<PasskeyApplication>) -> Router {
pub fn router(
readiness: Arc<dyn Readiness>,
passkeys: Option<PasskeyApplication>,
oidc: Option<OidcApplication>,
) -> Router {
let health = Router::new()
.route("/health/live", get(|| async { StatusCode::NO_CONTENT }))
.route("/health/ready", get(ready))
.with_state(AppState { readiness });
if let Some(passkeys) = passkeys {
let router = passkeys.map_or(health.clone(), |passkeys| {
health.merge(passkey::routes(passkeys))
} else {
health
}
});
oidc.map_or(router.clone(), |oidc| router.merge(oidc::routes(oidc)))
}

async fn ready(State(state): State<AppState>) -> impl IntoResponse {
Expand All @@ -155,7 +165,7 @@ mod tests {

#[tokio::test]
async fn liveness_has_no_dependencies_and_readiness_fails_closed() {
let app = router(Arc::new(FixedReadiness(false)), None);
let app = router(Arc::new(FixedReadiness(false)), None, None);
let live = app
.clone()
.oneshot(
Expand All @@ -179,7 +189,7 @@ mod tests {

#[tokio::test]
async fn readiness_succeeds_with_test_substitutes() {
let response = router(Arc::new(FixedReadiness(true)), None)
let response = router(Arc::new(FixedReadiness(true)), None, None)
.oneshot(
axum::http::Request::get("/health/ready")
.body(axum::body::Body::empty())
Expand Down
40 changes: 34 additions & 6 deletions apps/auth-service/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#![allow(missing_docs)]

use auth_service::{AuthConfig, Es256KeyProvider, PasskeyApplication, ProductionReadiness, router};
use auth_service::{
AuthConfig, Es256KeyProvider, OidcApplication, PasskeyApplication, ProductionReadiness, router,
};
use piquel_repository::Database;
use std::{net::SocketAddr, sync::Arc};

Expand All @@ -11,23 +13,49 @@ async fn main() -> anyhow::Result<()> {
let listener_address: SocketAddr = config.public_listener;
let database = Database::connect(config.database).await?;
let key_secret = config.key_provider.resolve()?;
let pem = std::str::from_utf8(key_secret.expose_secret())
.map_err(|_| anyhow::anyhow!("signing key provider returned invalid data"))?;
let purpose_keys = Es256KeyProvider::from_pkcs8_pem(config.signing_key_id.clone(), pem)
.map_err(|()| anyhow::anyhow!("signing key provider returned an invalid ES256 key"))?;
let keys = if config.development_mode {
Arc::new(Es256KeyProvider::generate_for_development(
config.signing_key_id.clone(),
))
} else {
let pem = std::str::from_utf8(key_secret.expose_secret())
.map_err(|_| anyhow::anyhow!("signing key provider returned invalid data"))?;
Arc::new(
Es256KeyProvider::from_pkcs8_pem(config.signing_key_id.clone(), pem).map_err(|()| {
anyhow::anyhow!("signing key provider returned an invalid ES256 key")
})?,
)
};
let passkeys = PasskeyApplication::new(
database.clone(),
&config.webauthn_rp_id,
config.public_base_url.as_url(),
Arc::new(purpose_keys),
Arc::clone(&keys),
)?;
let oidc = if config.development_mode {
OidcApplication::new_development(
database.clone(),
config.public_base_url.as_url(),
key_secret.expose_secret(),
keys,
)
} else {
OidcApplication::new(
database.clone(),
config.public_base_url.as_url(),
key_secret.expose_secret(),
keys,
)
}
.map_err(|()| anyhow::anyhow!("invalid OIDC configuration"))?;
let listener = tokio::net::TcpListener::bind(listener_address).await?;
tracing::info!(%listener_address, "auth service listening");
axum::serve(
listener,
router(
Arc::new(ProductionReadiness::new(database, config.key_provider)),
Some(passkeys),
Some(oidc),
),
)
.with_graceful_shutdown(shutdown_signal())
Expand Down
Loading