๐ skyauth
Pure Safe Rust (
#![forbid(unsafe_code)]), Zero-Panic AT Protocol OAuth 2.1 Client with RFC 9449 DPoP, RFC 9126 PAR, RFC 7636 PKCE, & Formal Mathematical Verification
๐ Highlights
- 100% Pure Safe Rust:
#![forbid(unsafe_code)]enforced crate-wide with 0unsafeblocks and zero production panics. - RFC 9449 DPoP: Ephemeral ECDSA P-256 key generation, RFC 7517 JWK formatting, RFC 7638 JWK Thumbprints (
jkt), signeddpop+jwtproof tokens, access token hash (ath), and transparent auto-nonce retry negotiation. - RFC 9126 PAR (Pushed Authorization Requests): Direct back-channel pushing of authorization parameters with signed DPoP headers.
- RFC 7636 PKCE: High-entropy 43-character Base64URL verifier generation, SHA-256 S256 challenge derivation, and constant-time verification.
- Decentralized Identity Discovery: Handle normalization, DNS TXT resolution (
_atproto.<handle>), HTTPS fallback (/.well-known/atproto-did), DID resolution (did:plc,did:web), and bidirectionalalsoKnownAsverification. - RFC 8414 & RFC 9728 Discovery: Protected Resource Metadata and Authorization Server Metadata discovery with automatic OIDC fallback.
- Strict SSRF & DNS Rebinding Security: Full IP boundary filtering blocking RFC 1918 private IPs, loopback, link-local, cloud metadata (
169.254.169.254), IPv6 ULA, and DNS socket pinning. - 64-Shard Partitioned State Store: Lock-free scaling state storage across 64 independent
RwLockshards with atomic single-use state consumption ([OAuthStore::take_state]) and drift-free background TTL pruning. - Web Framework Integrations: Ready-to-use extractors, response generators, and middleware for Axum 0.7, Actix-Web 4, and Tower.
- Formal Mathematical Verification: Verified using Verus deductive proofs (69 obligations across two layers, including kernel-bound contracts on the shipped IP-classification source), Kani bounded model checking with 57 machine-inventoried anti-vacuity reachability tags enforced across 8 symbolic proof harnesses (SSRF IPv4/IPv6 classifiers, constant-time equality, PKCE byte-level validator refinement, DPoP
jtiadmission bound, DPoPhtunormalization invariants, PKCE S256 verifier bounds, state consumption), and pure-Rust executable state transition models. Tag inventory and counts are machine-checked bytests/verification_tag_inventory_tests.rs; CI fails on any unsatisfiedkani::cover!property. - Public-Client Profile (strict):
skyauthimplements only the public-clienttoken_endpoint_auth_method: "none"path โ the ATProto OAuth profile has no sharedclient_secret(confidential clients authenticate withprivate_key_jwt, planned for a future release). Static-secret support was removed as a credential-disclosure hazard (review H1). - Proxied-Deployment DPoP:
with_htu_overrideon the Tower layer reconstructs absolute DPoP target URIs for servers behind reverse proxies receiving origin-form request targets. - Hardened SSRF Boundary: Deprecated 6to4 (
2002::/16, with embedded-IPv4 re-evaluation) and Teredo (2001::/32) tunneling prefixes are blocked, mirrored in the formal verification models; test mode (allow_insecure_localhost) only exempts explicit loopback targets, never metadata/internal hosts. - Single-Use Server Nonces: Optional strict RFC 9449 ยง 8 nonce consumption (
InMemoryServerNonceSource::with_single_use). - Resource-Server Token Validation:
JwtAccessTokenValidator(RFC 9068at+jwtverification with fail-closed issuer/audience matching andcnf.jktDPoP binding) and an in-memory registry, with a Tower middleware layer enforcing DPoP proof verification, replay rejection, and server nonce challenges. - XRPC Client Hardening: Lexicon NSID grammar validation on
send_xrpc_request, DPoP-signed requests with automatic nonce retry, and bounded response bodies. - Dynamic Schema Invariants: Bundled official ATProto Lexicons and RFC schemas with continuous automated upstream drift detection.
๐ Quick Start
Add skyauth to your Cargo.toml:
[]
= "0.3"
1. DPoP Proof Generation & Verification
use ;
use PkcePair;
2. Full OAuth Client Lifecycle
use ;
use OAuthStateStore;
use Arc;
use Duration;
async
๐ก๏ธ Formal Verification & Mathematical Invariants
skyauth incorporates a multi-layered formal verification hierarchy:
- Verus Deductive Contracts (
verus!): Deductive mathematical proofs in two layers โ the standalone specification layer (src/verification/verus_contracts.rs, 21 obligations) and the kernel-bound layer (src/verification/verus_kernels.rs, 48 obligations), whose contracts are proven over the shipped kernel source insrc/kernels/via#[path]inclusion: full IPv4/IPv6 restricted-range coverage theorems (RFC 1918, loopback, cloud metadata, CGNAT, Teredo, 6to4 embedded-IPv4 parity, mappedโIPv4 reduction, ULA, link-local, multicast, documentation, plus public non-vacuity witnesses). SMT solving (Z3) verifies single-use state transition safety, terminality, SSRF IP range isolation, and PKCE bounds. - Kani Bounded Model Checking (
kani::proof): Exhaustive symbolic proof harnesses insrc/verification/kani_harnesses.rsusing symbolickani::any()andkani::assume()inputs with 57 mandatory anti-vacuity reachability tags (kani::cover!/ [AntiVacuityCoverage]) that the deterministic test suite must reach. The tag inventory is machine-checked against the proof source bytests/verification_tag_inventory_tests.rs(bidirectional exact match), and CI fails the build on anyUNSATISFIABLEcover property. - Executable Formal State Models: High-assurance transition models in
src/verification/formal_models.rstested against property fuzzing and concurrent interleavings.
๐งช Running Tests, CI & Formal Proofs
# Run unit, integration, and RFC vector test suites
# Verify strict clippy compliance (0 warnings)
# Verify specification drift against upstream canonical Lexicons & RFC schemas
# Run Kani bounded model checking proof harnesses
# Run Verus deductive formal verification proofs
๐ License
Dual-licensed under either:
- MIT License (LICENSE-MIT)
- Apache License, Version 2.0 (LICENSE-APACHE)
Packaging Note
skyauth ships with empty default features (default = []): the core client library
compiles without any web-framework dependency. Framework integrations are opt-in
(axum, actix, tower). The tokio dependency is minimal (runtime, net, time, sync,
macros) rather than full.