Skip to main content

arete_auth/
lib.rs

1//! Arete Authentication Library
2//!
3//! This crate provides authentication and authorization utilities for Arete,
4//! including JWT token handling, claims validation, and key management.
5
6pub mod audit;
7pub mod claims;
8pub mod error;
9pub mod keys;
10pub mod metrics;
11pub mod multi_key;
12pub mod program_read;
13pub mod revocation;
14pub mod solana_gateway;
15pub mod token;
16pub mod verifier;
17
18pub use audit::{
19    auth_failure_event, auth_success_event, rate_limit_event, AuditEvent, AuditSeverity,
20    ChannelAuditLogger, NoOpAuditLogger, SecurityAuditEvent, SecurityAuditLogger,
21};
22pub use claims::{AuthContext, KeyClass, Limits, SessionClaims, TargetKind};
23pub use error::{AuthError, AuthErrorCode, RetryPolicy, VerifyError};
24pub use keys::{KeyLoader, SigningKey, VerifyingKey};
25pub use metrics::{AuthMetrics, AuthMetricsCollector, AuthMetricsSnapshot};
26pub use multi_key::{MultiKeyVerifier, MultiKeyVerifierBuilder, RotationKey};
27pub use program_read::{ProgramReadAuthorization, ProgramReadAuthorizationError};
28pub use revocation::{RevocationChecker, TokenRevocationList};
29pub use solana_gateway::{
30    SolanaGatewayAuthorization, SolanaGatewayAuthorizationError, SolanaGatewayScope,
31};
32pub use token::{TokenError, TokenSigner, TokenVerifier};
33pub use verifier::{AsyncVerifier, SimpleVerifier};
34
35/// Stable JWT audience for the shared program-read service.
36pub const PROGRAM_READ_AUDIENCE: &str = "arete:program-read";
37
38/// Stable JWT audience shared by all regional Solana gateways.
39pub const SOLANA_GATEWAY_AUDIENCE: &str = "arete:solana-gateway";
40
41/// Exact scope for chain reads.
42pub const SCOPE_READ: &str = "read";
43
44/// Exact scope for transaction inspection operations.
45pub const SCOPE_TRANSACTION_INSPECT: &str = "transaction:inspect";
46
47/// Exact scope for transaction submission.
48pub const SCOPE_TRANSACTION_SEND: &str = "transaction:send";
49
50/// Default session token TTL in seconds (5 minutes)
51pub const DEFAULT_SESSION_TTL_SECONDS: u64 = 300;
52
53/// Refresh window in seconds before expiry (60 seconds)
54pub const DEFAULT_REFRESH_WINDOW_SECONDS: u64 = 60;