pub struct OAuthState {Show 64 fields
pub clients: RwLock<HashMap<String, RegisteredClient>>,
pub cimd_cache: Arc<CimdCache>,
pub jwks_uri_cache: RwLock<HashMap<String, (Value, Instant)>>,
pub client_jwks_uri_cache_ttl: Duration,
pub pending_codes: RwLock<HashMap<String, PendingAuthCode>>,
pub pending_nonces: RwLock<HashMap<String, Instant>>,
pub pending_authorize_bindings: RwLock<HashMap<String, AuthorizeBinding>>,
pub pending_par_requests: RwLock<HashMap<String, PushedAuthRequest>>,
pub pending_device_codes: RwLock<HashMap<String, PendingDeviceCode>>,
pub device_code_by_user_code: RwLock<HashMap<String, String>>,
pub token_db: Option<Arc<dyn TokenStore>>,
pub policy_client: PolicyClient,
pub discovery_client: DiscoveryClient,
pub issuer_url: String,
pub hosted_account_zone: Option<AccountZone>,
pub ninep_canonical_read: Option<NinepCanonicalReadConfig>,
pub default_scopes: Vec<String>,
pub token_ttl: u32,
pub refresh_token_ttl: u32,
pub require_pushed_authorization_requests: bool,
pub http_client: Client,
pub verifying_key_bytes: [u8; 32],
pub user_service: Option<Arc<UserService>>,
pub hosted_account_store: Option<Arc<AccountRecordStore>>,
pub identity_registration_api: Option<Arc<IdentityRegistrationApi>>,
pub signing_key: Option<SigningKey>,
pub root_identity_key_store: Option<Arc<SigningKeyStore>>,
pub authority_hints: Vec<String>,
pub pending_external_auths: RwLock<HashMap<String, PendingExternalAuth>>,
pub external_providers: HashMap<String, OidcProviderConfig>,
pub oidc_discovery: SharedDiscoveryCache,
pub sessions: SessionStore,
pub xrpc_repos: Arc<XrpcRepoStore>,
pub public_repo_writer: Option<Arc<PublicRepoWriter>>,
pub hosted_public_repo_writer: Option<Arc<HostedAccountPublicRepoWriter>>,
pub public_git_canary_record: Option<PublicGitCanaryRecord>,
pub atproto_session_resolver: Option<Arc<dyn AtprotoSessionResolver>>,
pub xrpc_read_slice: bool,
pub public_git_canary_backend_port: Option<u16>,
pub deployment_well_known_dir: Option<PathBuf>,
pub rsa_encoding_key: Option<EncodingKey>,
pub rsa_jwk: Option<Value>,
pub rsa_kid: Option<String>,
pub dpop_jti_seen: TtlCache<ReplayKey, ()>,
pub assertion_jti_seen: TtlCache<ReplayKey, ()>,
pub atproto_service_jti_seen: TtlCache<ReplayKey, ()>,
pub atproto_did_resolver: Arc<dyn AtprotoDidDocumentResolver>,
pub dpop_nonces: RwLock<HashMap<String, i64>>,
pub dpop_clients_seen: RwLock<HashMap<String, i64>>,
pub trusted_issuers: HashMap<String, TrustedIssuerConfig>,
pub ca_jwt_key: Option<Arc<SigningKey>>,
pub device_store: Option<Arc<dyn DeviceStore>>,
pub jwt_key_nbf: i64,
pub jwt_key_exp: i64,
pub signing_key_store: Option<Arc<SigningKeyStore>>,
pub es256_key_store: Option<Arc<Es256SigningKeyStore>>,
pub ml_dsa_key_store: Option<Arc<MlDsaSigningKeyStore>>,
pub audit_sink: Option<Arc<dyn AuditSink>>,
pub quic_cert_hashes: Vec<[u8; 32]>,
pub quic_public_uri: Option<String>,
pub mesh_pq_verifying_key: Option<Vec<u8>>,
pub mesh_kem_public: Option<RecipientPublic>,
pub iroh_node_id: Option<[u8; 32]>,
pub iroh_relays: Vec<String>,
/* private fields */
}Expand description
Shared OAuth server state.
Fields§
§clients: RwLock<HashMap<String, RegisteredClient>>Dynamically-registered (RFC 7591) clients keyed by issued UUID
client_id. CIMD clients live in cimd_cache instead — DCR
entries have no TTL and outlive cache evictions, so storage is
separated.
cimd_cache: Arc<CimdCache>CIMD metadata cache. CIMD documents (HTTPS-URL client_ids) are
fetched + verified once, then cached respecting HTTP cache
headers, bounded TTL and capacity. See cimd_cache module.
jwks_uri_cache: RwLock<HashMap<String, (Value, Instant)>>JWKS-URI fetch cache for private_key_jwt client auth. Keyed by
the absolute URL; value is (parsed_jwks_json, fetched_at).
Entries expire after client_jwks_uri_cache_ttl_secs and are
evicted lazily on read. Capacity is implicitly bounded by the
number of registered clients with jwks_uri (typically small).
client_jwks_uri_cache_ttl: DurationTTL for the jwks_uri_cache. Copied from
OAuthConfig::client_jwks_uri_cache_ttl_secs at construction.
pending_codes: RwLock<HashMap<String, PendingAuthCode>>Pending authorization codes (single-use, 60s TTL)
pending_nonces: RwLock<HashMap<String, Instant>>Pending authorize nonces (single-use, 5-min TTL). Proves a nonce was issued by this server and hasn’t been replayed.
Complete resolved authorization requests, keyed and consumed alongside the consent nonce so browser-carried fields are never authority.
pending_par_requests: RwLock<HashMap<String, PushedAuthRequest>>Pending Pushed Authorization Requests (RFC 9126), keyed by request_uri.
Single-use, 60s TTL. In-memory is correct here — no value to persistence.
pending_device_codes: RwLock<HashMap<String, PendingDeviceCode>>Pending device authorization codes (RFC 8628), keyed by device_code
device_code_by_user_code: RwLock<HashMap<String, String>>Reverse lookup: user_code -> device_code
token_db: Option<Arc<dyn TokenStore>>Persistent refresh token store. Keyed by opaque token string. None when no credentials path is configured (tokens silently lost on restart).
policy_client: PolicyClientPolicyClient for JWT token issuance via ZMQ
discovery_client: DiscoveryClientDiscoveryClient for resolving service QUIC endpoints via ZMQ
issuer_url: StringIssuer URL (e.g., “http://localhost:6791”)
hosted_account_zone: Option<AccountZone>Deployment-owned account-zone apex. User tokens may carry only a tenant derived from a hosted DID under this exact configured zone.
ninep_canonical_read: Option<NinepCanonicalReadConfig>Operator-selected canonical 9P read export. When set, hosted-account
signup seeds the new account’s HolderGate baseline rows
(model:{repo} query, registry:{repo-uuid} query) in its tenant.
default_scopes: Vec<String>Default scopes for new clients
token_ttl: u32Access token TTL in seconds
refresh_token_ttl: u32Refresh token TTL in seconds
When true, /oauth/authorize rejects inline params and requires a request_uri
from a prior /oauth/par call (RFC 9126). Advertised in server metadata.
http_client: ClientHTTP client for fetching Client ID Metadata Documents
verifying_key_bytes: [u8; 32]Raw Ed25519 verifying key bytes (32 bytes) for the JWKS endpoint.
user_service: Option<Arc<UserService>>User credential store for Ed25519 challenge-response device verification.
Now backed by user_service. Legacy code uses user_store_reader().
Kept as Option for backward-compatible is_none() checks.
hosted_account_store: Option<Arc<AccountRecordStore>>Authority-owned hosted-account records used to resolve an ATProto DID
to its local tenant binding. None means every ATProto identity is
federated-only for tenant exchange purposes.
identity_registration_api: Option<Arc<IdentityRegistrationApi>>Authenticated registration/intake wire adapter. None keeps every
identity mutation endpoint fail-closed with 503 after authentication.
signing_key: Option<SigningKey>Ed25519 signing key for signing entity configurations (OpenID Federation 1.0).
None when not configured.
root_identity_key_store: Option<Arc<SigningKeyStore>>Named root-DID identity slots (drain/active/lead).
This store is seeded from signing_key on first deployment, then rotated
independently with bounded overlap. The root DID publisher snapshots all
three roles; entity statements sign with the active role.
OpenID Federation 1.0 Trust Anchor URLs.
Included as authority_hints in the entity configuration JWT.
pending_external_auths: RwLock<HashMap<String, PendingExternalAuth>>Pending external OIDC authentication flows (keyed by external state).
external_providers: HashMap<String, OidcProviderConfig>Provider configuration fixed at server construction for a consistent authorize page, upstream start, and callback verification.
oidc_discovery: SharedDiscoveryCacheOIDC discovery cache for external providers.
sessions: SessionStoreServer-side session store for browser login flow.
xrpc_repos: Arc<XrpcRepoStore>In-memory com.atproto.* XRPC read slice repo store (#1112). Populated
by the write path (#910) and tests; the read endpoints consult it
directly. Default-empty so existing construction sites need no change.
public_repo_writer: Option<Arc<PublicRepoWriter>>Optional native-authorized public repository writer. No public write routes are mounted while this is absent.
hosted_public_repo_writer: Option<Arc<HostedAccountPublicRepoWriter>>Production hosted-account writer. It resolves the requested DID and signs through AccountRecordStore without exposing private key bytes.
public_git_canary_record: Option<PublicGitCanaryRecord>One explicitly enabled Registry/PDS record. Its DID and rkey are fixed at startup; public callers cannot select another Discovery target.
atproto_session_resolver: Option<Arc<dyn AtprotoSessionResolver>>Optional native account resolver for the protected standard
com.atproto.server.getSession route.
xrpc_read_slice: boolWhen true, the XRPC read-slice routes (/xrpc/…) are mounted on the
OAuth router (#1112). Copied from OAuthConfig::xrpc_read_slice.
public_git_canary_backend_port: Option<u16>Optional loopback-only sidecar port for the fixed public Git canary.
None keeps the Git routes absent from the public router.
deployment_well_known_dir: Option<PathBuf>Deployment static well-known directory (#1137 serving half). When set,
this OAuth instance terminates the deployment’s did:web host: it serves
<dir>/did.json in place of the dynamic node document, plus
<dir>/at9p/<cid>.cbor,
<dir>/deployment/deployment-authority.log.json, and
<dir>/deployment/registry-service.jwt. All four are public,
integrity-anchored bytes — see
deployment_well_known.rs. Copied from
OAuthConfig::deployment_well_known_dir.
rsa_encoding_key: Option<EncodingKey>RSA encoding key for RS256 id_token signing (optional, loaded from secrets).
rsa_jwk: Option<Value>RSA public key as JWK JSON (for the JWKS endpoint).
rsa_kid: Option<String>RSA key kid (for the JWT header).
dpop_jti_seen: TtlCache<ReplayKey, ()>Seen DPoP JTIs for replay prevention (RFC 9449 §11.1). Backed by
the shared TtlCache with atomic check-and-record — see
check_and_record_dpop_jti. A BLAKE3-256 digest retains a fixed-size
key; TTL = iat + 120s per entry.
assertion_jti_seen: TtlCache<ReplayKey, ()>Seen client-assertion JTIs for replay prevention (RFC 7523 §3 /
atproto OAuth; #1146 T3.3). Keyed by a BLAKE3-256 digest of
{client_id}\u{1f}{jti}; TTL = the assertion’s remaining exp
lifetime. See
check_and_record_assertion_jti.
atproto_service_jti_seen: TtlCache<ReplayKey, ()>One-use ATProto service-auth JTIs, keyed by a BLAKE3-256 digest of the issuer/JTI composite and retained until the source assertion expires.
atproto_did_resolver: Arc<dyn AtprotoDidDocumentResolver>Validated did:plc/did:web document source for service-auth keys.
dpop_nonces: RwLock<HashMap<String, i64>>Server-issued DPoP nonces. Value = expiry unix timestamp.
dpop_clients_seen: RwLock<HashMap<String, i64>>Per-client (keyed by DPoP jkt thumbprint) nonce-issuance state.
Once a jkt appears here, RFC 9449 §8 enforcement kicks in: subsequent
proofs from the same key MUST carry a server-issued nonce. Value =
expiry unix timestamp (matches nonce TTL; entry pruned when expired
to allow re-bootstrap after silence).
trusted_issuers: HashMap<String, TrustedIssuerConfig>Trusted external OIDC issuers for the JWT bearer grant (RFC 7523).
ca_jwt_key: Option<Arc<SigningKey>>CA JWT signing key for browser WIT issuance (POST /oauth/wit). Derived from the root CA key via derive_purpose_key(“hyprstream-jwt-v1”). None when credentials are unavailable (WIT endpoint returns 503).
device_store: Option<Arc<dyn DeviceStore>>Anonymous device identity store.
jwt_key_nbf: i64Unix timestamp of when the JWT signing key became active (nbf for JWKS entry).
jwt_key_exp: i64Unix timestamp of when the JWT signing key expires (exp for JWKS entry). Default: jwt_key_nbf + 14 days.
signing_key_store: Option<Arc<SigningKeyStore>>Multi-slot JWT signing key store for rotation (drain/active/lead lifecycle). When present, JWKS serves all slots and issuance uses the active key.
es256_key_store: Option<Arc<Es256SigningKeyStore>>Shared JWT ID blocklist for access token revocation (shared with PolicyService). ES256 (P-256) signing key rotation store for JWKS and DPoP/atproto interop.
ml_dsa_key_store: Option<Arc<MlDsaSigningKeyStore>>ML-DSA-65 signing key rotation store for PQ-hybrid JWT issuance.
audit_sink: Option<Arc<dyn AuditSink>>MAC #547 / B2 (#674): the tamper-evident audit sink the S6 grant path
(mac::exchange::audited_evaluate_grant/audited_evaluate_refresh)
records every decision through. None means the grant-path audit
trail is not configured — the grant path treats that as fail-closed
(deny, not “audit best-effort”) rather than minting unaudited tokens.
Production wiring is crate::mac::audit::WalAuditStore + an
crate::mac::audit::cose::OwnedCoseAuditSigner (see the oauth
service factory).
quic_cert_hashes: Vec<[u8; 32]>QUIC/WebTransport cert hashes (SHA-256 of leaf DER, sha2-256 multihash encoding).
Published in the DID-doc #quic service entry so peers can pin the cert (#185).
A set so cert rotation can publish old + new simultaneously.
quic_public_uri: Option<String>Public QUIC URI (https://host:port) for the DID-doc service entry (#185).
None until the QUIC server is started and the cert hash is known.
mesh_pq_verifying_key: Option<Vec<u8>>Raw ML-DSA-65 verifying-key bytes (1952 bytes) for the node’s mesh
post-quantum signing key (#157). Published as the #mesh-pq Multikey
verification method in the root DID document. Derived from the same
Ed25519 key as Self::signing_key (via derive_mesh_mldsa_key), so
the published VM equals the key the node signs mesh responses with.
None when the entity signing key is not configured.
mesh_kem_public: Option<RecipientPublic>The node’s #mesh-kem hybrid keyAgreement public material (S1 / #552):
one ML-KEM-768-hybrid recipient public (X25519 + ML-KEM-768 encapsulation
keys, suite HyKemX25519MlKem768). Published as the keyAgreement
verification methods in the root DID document. Derived from the same
Ed25519 key as Self::signing_key (via derive_mesh_kem_recipient),
so the published keys equal what the node decapsulates #mesh-kem
envelopes with. None when the entity signing key is not configured,
or when derivation failed under Classical policy (Hybrid fails closed
during with_signing_key).
iroh_node_id: Option<[u8; 32]>#282: the node’s iroh endpoint id (its Ed25519 node_id, 32 bytes),
published only as an IrohTransport service entry when bound. It is not
a verification method or JWKS key (#1031).
iroh_relays: Vec<String>#282: iroh relay URLs to advertise in the IrohTransport entry’s
relays. Empty = rely on pkarr/DNS discovery for reachability (the
peer resolves direct paths by node_id alone).
Implementations§
Source§impl OAuthState
impl OAuthState
pub fn new( config: &OAuthConfig, policy_client: PolicyClient, discovery_client: DiscoveryClient, verifying_key_bytes: [u8; 32], ) -> Self
Sourcepub fn with_device_store(self, store: Arc<dyn DeviceStore>) -> Self
pub fn with_device_store(self, store: Arc<dyn DeviceStore>) -> Self
Attach the anonymous device store.
Sourcepub fn with_atproto_did_resolver(
self,
resolver: Arc<dyn AtprotoDidDocumentResolver>,
) -> Self
pub fn with_atproto_did_resolver( self, resolver: Arc<dyn AtprotoDidDocumentResolver>, ) -> Self
Override ATProto DID resolution with a validated fixture or private resolver.
Sourcepub fn with_hosted_account_store(self, store: Arc<AccountRecordStore>) -> Self
pub fn with_hosted_account_store(self, store: Arc<AccountRecordStore>) -> Self
Attach the authority-owned hosted-account record store.
Sourcepub fn with_public_repo_writer(self, writer: Arc<PublicRepoWriter>) -> Self
pub fn with_public_repo_writer(self, writer: Arc<PublicRepoWriter>) -> Self
Install the explicit native-authorized public repository writer. This opt-in is required before standard XRPC repository writes are exposed.
pub fn with_hosted_public_repo_writer( self, writer: Arc<HostedAccountPublicRepoWriter>, ) -> Self
pub fn with_public_git_canary_record( self, record: PublicGitCanaryRecord, ) -> Self
Sourcepub fn with_atproto_session_resolver(
self,
resolver: Arc<dyn AtprotoSessionResolver>,
) -> Self
pub fn with_atproto_session_resolver( self, resolver: Arc<dyn AtprotoSessionResolver>, ) -> Self
Install the explicit native account resolver used by standard
com.atproto.server.getSession. The resolver owns handle, DID-document
and lifecycle truth; no session route is mounted without it.
Sourcepub fn with_identity_registration_api(
self,
api: Arc<IdentityRegistrationApi>,
) -> Self
pub fn with_identity_registration_api( self, api: Arc<IdentityRegistrationApi>, ) -> Self
Attach the authenticated hosted-account registration/intake adapter.
Sourcepub async fn hosted_account_tenant(
&self,
did: &str,
) -> Result<Option<String>, String>
pub async fn hosted_account_tenant( &self, did: &str, ) -> Result<Option<String>, String>
Resolve a signed ATProto subject DID to its hosted local tenant.
The request tenant is deliberately absent from this API. A missing
store or record is a federated-only identity (Ok(None)); store
corruption, authorization failure, and ambiguous bindings are errors.
Sourcepub async fn refresh_hosted_account_index_after_signup(
&self,
) -> Result<(), String>
pub async fn refresh_hosted_account_index_after_signup( &self, ) -> Result<(), String>
Refresh the authority-owned hosted-DID index after OAuth signup has durably published and activated an account. This is a no-op when the production hosted-account store is not configured, preserving the existing non-local-store path.
Sourcepub fn atproto_service_did(&self) -> Option<String>
pub fn atproto_service_did(&self) -> Option<String>
Host service DID accepted in ATProto service-auth aud.
Sourcepub fn with_jwt_key_timestamps(self, nbf: i64, exp: i64) -> Self
pub fn with_jwt_key_timestamps(self, nbf: i64, exp: i64) -> Self
Set JWT signing key validity window for the JWKS endpoint.
Sourcepub fn with_ca_jwt_key(self, key: SigningKey) -> Self
pub fn with_ca_jwt_key(self, key: SigningKey) -> Self
Attach the CA JWT signing key for browser WIT issuance (POST /oauth/wit).
Sourcepub fn with_signing_key_store(self, store: Arc<SigningKeyStore>) -> Self
pub fn with_signing_key_store(self, store: Arc<SigningKeyStore>) -> Self
Attach the multi-slot signing key store (rotation).
When set, JWKS serves all slots and WIT issuance uses the active key.
Sourcepub fn with_root_identity_key_store(self, store: Arc<SigningKeyStore>) -> Self
pub fn with_root_identity_key_store(self, store: Arc<SigningKeyStore>) -> Self
Attach the independently persisted root-DID identity rotation set.
Sourcepub fn with_es256_key_store(self, store: Arc<Es256SigningKeyStore>) -> Self
pub fn with_es256_key_store(self, store: Arc<Es256SigningKeyStore>) -> Self
Attach the ES256 (P-256) key rotation store.
Sourcepub fn with_ml_dsa_key_store(self, store: Arc<MlDsaSigningKeyStore>) -> Self
pub fn with_ml_dsa_key_store(self, store: Arc<MlDsaSigningKeyStore>) -> Self
Attach the ML-DSA-65 key rotation store.
Sourcepub fn with_audit_sink(self, sink: Arc<dyn AuditSink>) -> Self
pub fn with_audit_sink(self, sink: Arc<dyn AuditSink>) -> Self
Attach the S6 grant-path audit sink (B2, #674). Without this, the grant path fails closed on every request rather than minting tokens with no audit trail.
Sourcepub fn with_quic_transport(
self,
public_uri: String,
cert_hashes: Vec<[u8; 32]>,
) -> Self
pub fn with_quic_transport( self, public_uri: String, cert_hashes: Vec<[u8; 32]>, ) -> Self
Set the node’s QUIC transport info for DID-doc publication (#185).
cert_hashes is the set of SHA-256 cert DER hashes currently in use
(old + new during rotation). public_uri is https://host:port that
external peers dial.
Sourcepub fn with_iroh_transport(self, node_id: [u8; 32], relays: Vec<String>) -> Self
pub fn with_iroh_transport(self, node_id: [u8; 32], relays: Vec<String>) -> Self
Set the node’s iroh transport info for DID-doc publication (#282).
Call this only when the iroh substrate is actually bound: it makes
root_did_document advertise an IrohTransport service entry. The
node_id is reachability metadata, never a DID verification method.
relays may be empty — peers then resolve reachability by node_id alone
via iroh’s pkarr/DNS discovery.
Sourcepub async fn jwt_bearer_verifying_key(&self) -> Option<VerifyingKey>
pub async fn jwt_bearer_verifying_key(&self) -> Option<VerifyingKey>
Return the verifying key to use for JWT bearer token validation.
Prefers the active slot from the signing key store; falls back to the
legacy verifying_key_bytes field (policy-service-issued key).
Sourcepub async fn active_jwt_signing_key(&self) -> Option<Arc<SigningKey>>
pub async fn active_jwt_signing_key(&self) -> Option<Arc<SigningKey>>
Return the active JWT signing key for token issuance (WIT/ADT).
Prefers the active slot from the signing key store; falls back to ca_jwt_key.
Sourcepub async fn active_root_identity_signing_key(&self) -> Option<Arc<SigningKey>>
pub async fn active_root_identity_signing_key(&self) -> Option<Arc<SigningKey>>
Active root-DID signing key, falling back to the pre-rotation singleton.
Sourcepub fn with_user_store(self, store: ProductionUserStore) -> Self
pub fn with_user_store(self, store: ProductionUserStore) -> Self
Attach an account store admitted by the sole production construction boundary.
Sourcepub fn with_hosted_account_zone(self, zone: AccountZone) -> Self
pub fn with_hosted_account_zone(self, zone: AccountZone) -> Self
Bind token issuance to the account zone this deployment actually hosts.
Sourcepub fn with_ninep_canonical_read(self, export: NinepCanonicalReadConfig) -> Self
pub fn with_ninep_canonical_read(self, export: NinepCanonicalReadConfig) -> Self
Attach the operator-selected canonical 9P read export so hosted-account signup can seed the HolderGate baseline rows for new accounts.
Sourcepub fn has_user_store(&self) -> bool
pub fn has_user_store(&self) -> bool
Backward-compatible check: returns true if a user store is configured.
Sourcepub fn with_signing_key(
self,
key: SigningKey,
policy: CryptoPolicy,
) -> Result<Self>
pub fn with_signing_key( self, key: SigningKey, policy: CryptoPolicy, ) -> Result<Self>
Attach the signing key for OpenID Federation 1.0 entity configuration signing.
Also derives and stores the node’s mesh ML-DSA-65 verifying key (#157)
from this same Ed25519 key, so the root DID document’s #mesh-pq
Multikey verification method matches the post-quantum key the mesh signs
with (derive_mesh_mldsa_key), and the node’s #mesh-kem hybrid
keyAgreement public material (S1 / #552, derive_mesh_kem_recipient) so
peers can anchor a recipient key that matches what this node decapsulates
with. A #mesh-kem derivation failure is fail-closed under Hybrid
policy: startup returns an error rather than publishing a root DID
document with an empty keyAgreement relationship. Under Classical
policy, the failure is logged and mesh_kem_public stays unset.
Sourcepub fn with_token_store_impl(&mut self, store: Arc<dyn TokenStore>)
pub fn with_token_store_impl(&mut self, store: Arc<dyn TokenStore>)
Inject a pre-built token store implementation.
Sourcepub async fn put_refresh_token(
&self,
token: &str,
entry: &RefreshTokenEntry,
ttl_secs: u64,
) -> Result<()>
pub async fn put_refresh_token( &self, token: &str, entry: &RefreshTokenEntry, ttl_secs: u64, ) -> Result<()>
Persist a refresh token entry to the store.
Sourcepub async fn get_refresh_token(
&self,
token: &str,
) -> Result<Option<RefreshTokenEntry>>
pub async fn get_refresh_token( &self, token: &str, ) -> Result<Option<RefreshTokenEntry>>
Look up a refresh token. Returns None if not found or expired (lazy expiry).
Sourcepub async fn take_refresh_token(
&self,
token: &str,
) -> Result<Option<RefreshTokenEntry>>
pub async fn take_refresh_token( &self, token: &str, ) -> Result<Option<RefreshTokenEntry>>
Atomically claim a refresh token for one-time rotation. Only one caller across all OAuth replicas can receive a given entry.
Sourcepub async fn delete_refresh_token(&self, token: &str) -> Result<()>
pub async fn delete_refresh_token(&self, token: &str) -> Result<()>
Remove a refresh token (revocation / rotation).
Sourcepub fn check_and_record_dpop_jti(&self, jti: &str, iat: i64) -> bool
pub fn check_and_record_dpop_jti(&self, jti: &str, iat: i64) -> bool
Check a DPoP JTI for replay and record it if new.
Returns true when the JTI is fresh (caller should proceed).
Returns false when the JTI is a replay or the fail-closed barrier is full.
Expired entries are pruned opportunistically on each call.
Sourcepub fn check_and_record_atproto_service_jti(
&self,
issuer: &str,
jti: &str,
exp: i64,
) -> bool
pub fn check_and_record_atproto_service_jti( &self, issuer: &str, jti: &str, exp: i64, ) -> bool
Atomically consume an ATProto service-auth assertion identifier.
Sourcepub fn check_and_record_assertion_jti(
&self,
client_id: &str,
jti: &str,
exp: i64,
) -> bool
pub fn check_and_record_assertion_jti( &self, client_id: &str, jti: &str, exp: i64, ) -> bool
Check a client-assertion JTI for replay and record it if new
(#1146 T3.3; RFC 7523 §3 — an AS MUST NOT accept the same jti
more than once).
Keyed by {client_id}\u{1f}{jti} so distinct clients cannot
collide on the same identifier. The entry lives until the
assertion’s own exp, after which a replayed assertion would be
rejected as expired anyway.
Returns true when the JTI is fresh (caller should proceed);
false when it is a replay or the fail-closed barrier is full.
Sourcepub async fn issue_dpop_nonce(&self) -> String
pub async fn issue_dpop_nonce(&self) -> String
Issue a fresh server-side DPoP nonce (RFC 9449 §8).
Returns the base64url nonce string that should be placed in the
DPoP-Nonce response header. Stored with a 5-minute TTL.
Sourcepub async fn verify_dpop_nonce(&self, nonce: &str) -> bool
pub async fn verify_dpop_nonce(&self, nonce: &str) -> bool
Validate a DPoP nonce issued by this server. Returns true if valid and unexpired.
Sourcepub async fn dpop_client_requires_nonce(&self, jkt: &str) -> bool
pub async fn dpop_client_requires_nonce(&self, jkt: &str) -> bool
RFC 9449 §8 nonce-enforcement bookkeeping: has this client (jkt)
previously been issued a nonce that has not yet expired? If so the
next DPoP proof from this key MUST include a valid nonce.
Sourcepub async fn mark_dpop_client_nonced(&self, jkt: &str)
pub async fn mark_dpop_client_nonced(&self, jkt: &str)
Record that this client (jkt) has been issued a server nonce.
Future proofs from this key are required to carry one (sliding 5-min
window per nonce TTL).
Sourcepub fn subject_did(&self, subject: &str) -> Result<String, SubjectDidError>
pub fn subject_did(&self, subject: &str) -> Result<String, SubjectDidError>
Validate the JWT sub claim for an atproto-conformant access token
(#1113 rev2 / #1124 split).
atproto OAuth requires the access token’s sub to be a real,
resolvable atproto account DID: did:plc:<opaque> or host-form
did:web:<host>[:port] (NO path component — the atproto DID profile
rejects did:web:host:users:alice). A hyprstream-local account
(enrolled by Ed25519 username) has no atproto DID yet; provisioning
is tracked in #1124. Such accounts are REJECTED from the atproto
profile (fail closed), never minted a spec-invalid path-form alias.
Sourcepub fn atproto_issuer_url(&self) -> String
pub fn atproto_issuer_url(&self) -> String
Origin-only issuer required by the atproto OAuth profile.
Sourcepub fn issuer_for_scopes(&self, scopes: &[String]) -> String
pub fn issuer_for_scopes(&self, scopes: &[String]) -> String
Select the issuer used at a profile-sensitive mint/redirect boundary.
Sourcepub async fn check_atproto_account_eligibility(
&self,
username: &str,
) -> Result<String, SubjectDidError>
pub async fn check_atproto_account_eligibility( &self, username: &str, ) -> Result<String, SubjectDidError>
Check whether an account is eligible for the atproto OAuth profile and return the account’s mapped atproto DID (#1113 r5 / #1124 split).
This inspects the ACCOUNT/KEY MAPPING, not the subject string:
- Rejects at9p-backed accounts (any key with
[
KeyAlgorithm::HybridEd25519MlDsa65] →SubjectDidError::At9pBackedAccount). - Looks up the account’s MAPPED atproto DID from the profile’s
atproto_didfield. If present and valid → returns it (success). - An account without a mapped DID fails closed
(
SubjectDidError::NoAtprotoIdentity).
PROVISIONING mappings (creating did:plc, etc.) is #1124 — out of scope.
The LOOKUP + success path exists here so the atproto OAuth profile can
emit the mapped DID as sub when an account has one.
Sourcepub fn server_supported_scopes(&self) -> Vec<String>
pub fn server_supported_scopes(&self) -> Vec<String>
The full set of scopes this AS supports (#1113 rev2 F4).
Extends default_scopes (the omitted-scope grant set) with the
atproto transition scopes, which are supported-but-explicit: a client
must request them to activate the strict profile; omitting scope
grants only default_scopes.
Sourcepub fn with_rsa_key(self, rsa_der: &[u8]) -> Self
pub fn with_rsa_key(self, rsa_der: &[u8]) -> Self
Attach an RSA key for RS256 id_token signing (OIDC interop).
rsa_der is the PKCS#8 DER-encoded RSA private key.
Sourcepub fn spawn_code_sweeper(self: &Arc<Self>)
pub fn spawn_code_sweeper(self: &Arc<Self>)
Spawn a background task that sweeps expired codes every 30 seconds.
Auto Trait Implementations§
impl !Freeze for OAuthState
impl !RefUnwindSafe for OAuthState
impl Send for OAuthState
impl Sync for OAuthState
impl Unpin for OAuthState
impl UnsafeUnpin for OAuthState
impl !UnwindSafe for OAuthState
Blanket Implementations§
§impl<T> AnySync for T
impl<T> AnySync for T
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request