#![cfg_attr(not(test), deny(unsafe_code))]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
pub mod api;
pub mod crypto;
pub mod encoding;
pub mod json;
pub mod jwt;
pub mod local;
pub mod mfa;
pub mod oauth;
pub mod session;
pub mod util;
pub mod provider;
#[cfg(feature = "oidc")]
pub mod oidc;
#[cfg(feature = "saml")]
pub mod saml;
#[cfg(feature = "scim")]
pub mod scim;
#[cfg(feature = "ldap")]
pub mod ldap;
#[cfg(feature = "policy")]
pub mod policy;
#[cfg(feature = "saml")]
pub mod xml;
#[cfg(feature = "ssh-keys")]
pub mod ssh;
pub mod webauthn;
pub use crypto::constant_time::constant_time_eq;
pub use crypto::zeroize::{ZeroizeOnDrop, Zeroizing};
pub use crypto::{
HmacSha1, HmacSha256, HmacSha512, RandomError, Sha1, Sha256, Sha512, fill_random,
random_token_base64url, random_token_hex,
};
pub use encoding::{
Base32DecodeError, Base64DecodeError, HexDecodeError, UrlDecodeError, base32_decode,
base32_encode, base64_decode, base64_encode, base64url_decode, base64url_encode, hex_decode,
hex_encode, hex_encode_upper, url_decode, url_encode, url_encode_component,
};
pub use util::timestamp::Timestamp;
pub use util::validation::{
CLIENT_ID_RULES, DEFAULT_SPECIAL_CHARS, EMAIL_RULES, MAX_CLIENT_ID_LEN, MAX_EMAIL_LEN,
MAX_NAME_LEN, MAX_REDIRECT_URI_LEN, MAX_SCOPE_LEN, MAX_USERNAME_LEN, NAME_RULES,
PASSWORD_RULES, PasswordRules, REDIRECT_URI_RULES, SCOPE_RULES, USERNAME_RULES, is_https_url,
is_valid_client_id, is_valid_email, is_valid_name, is_valid_redirect_uri, is_valid_scope,
is_valid_username, validate_password_strength,
};
pub use local::password::{PasswordConfig, PasswordError, PasswordHash, verify_credential};
pub use local::{
CredentialStore, Credentials, InMemoryCredentialStore, InMemoryStoreError, StoredCredential,
Username, UsernameError,
};
pub use session::token::{generate_token, generate_token_with_hash, hash_token_for_lookup};
pub use session::{Session, SessionConfig, SessionError, SessionValidation};
pub use api::{
ApiKey, ApiKeyError, ApiKeyHash, BearerError, HmacAuthError, HmacRequestSigner,
HmacRequestVerifier, extract_bearer_token,
};
pub use json::{JsonParseError, JsonValue};
pub use jwt::{
IntoCustomClaim, JwtAlgorithm, JwtClaims, JwtClaimsError, JwtEncoder, JwtHeader,
JwtHeaderError, JwtSignatureError, JwtSigningAlgorithm, verify_jwt,
};
#[cfg(feature = "asym-jwt")]
pub use jwt::{
AsymmetricAlgorithm, AsymmetricKeyError, AsymmetricSigningKey, AsymmetricVerifyingKey, Jwk,
JwkError, JwkSet, KeyRing, verify_jwt_asymmetric,
};
pub use oauth::{
AuthorizationRequest, OAuthConfig, OAuthConfigBuilder, OAuthConfigError, OAuthState,
PkceChallenge, RefreshRequest, TokenExchangeRequest, TokenResponse, TokenResponseError,
};
pub use oauth::server::{
AuthorizeError, AuthorizeErrorCode, AuthorizeRedirectError, AuthorizeRequest, ClientAuthResult,
ClientCredentialsDenied, ClientCredentialsRequest, ClientCredentialsVerdict, ClientType,
CodeRedemptionDenied, CodeRedemptionVerdict, DisplayErrorReason, IdTokenBuilder,
IntrospectionResponse, RefreshDenied, RefreshOutcome, RefreshPresented, RegisteredClient,
RegisteredClientBuilder, RegisteredClientError, StoredAuthCode, StoredRefreshToken,
TokenRequestPresented, ValidatedAuthorizeRequest, evaluate_client_credentials,
evaluate_code_redemption, evaluate_refresh, validate_authorize_request,
};
#[cfg(feature = "asym-jwt")]
pub use oauth::server::{ClientAssertion, ClientAssertionDenied, verify_client_assertion};
#[cfg(feature = "oidc")]
pub use oidc::{
FederatedClaims, FederationContext, FederationDenied, FederationOutcome, FederationVerdict,
IdTokenClaims, IdTokenClaimsError, IdTokenError, IdTokenValidator, OidcDiscovery,
OidcDiscoveryError, UserInfo, UserInfoError, evaluate_federation,
};
#[cfg(feature = "saml")]
pub use saml::{
SamlAssertion, SamlAttribute, SamlConditions, SamlConfig, SamlConfigError, SamlResponse,
SamlResponseError, SamlStatus, SamlSubject, generate_sp_metadata,
};
#[cfg(feature = "saml")]
pub use xml::{XmlElement, XmlParseError, parse_xml, xml_escape};
pub use mfa::hibp::{BreachResult, HibpError, HibpPrefix, HibpResponse, hibp_sha1_hex};
pub use mfa::totp::{
TotpAlgorithm, TotpConfig, TotpError, TotpSecret, generate_recovery_codes, totp_generate,
totp_verify, totp_verify_step,
};
#[cfg(feature = "ssh-keys")]
pub use ssh::{SshKeyAlgorithm, SshKeyError, SshPublicKey};
pub use webauthn::{
AuthenticationCeremony, AuthenticationChallenge, AuthenticationOutcome, CredentialID,
InMemoryPasskeyStore, InMemoryPasskeyStoreError, PRF_SALT_LEN, Passkey, PasskeyAuthentication,
PasskeyCredential, PasskeyCredentialStore, PasskeyRegistration, PasskeyUser,
PrfAuthenticationRequest, PrfClientResult, PrfRegistrationRequest, PrfSalt,
PublicKeyCredential, RegisterPublicKeyCredential, RegistrationCeremony, RegistrationChallenge,
RegistrationOutcome, RelyingParty, RelyingPartyBuilder, StoredPasskey, Uuid, WebAuthnError,
};
pub use crate::crypto::secret_box::{SecretBox, SecretBoxError};
pub use provider::{AuthError, AuthIdentity, AuthProviderKind, AuthResult};
const _: () = {
const fn assert_send_sync<T: Send + Sync>() {}
assert_send_sync::<Sha1>();
assert_send_sync::<Sha256>();
assert_send_sync::<Sha512>();
assert_send_sync::<HmacSha1>();
assert_send_sync::<HmacSha256>();
assert_send_sync::<HmacSha512>();
assert_send_sync::<Base32DecodeError>();
assert_send_sync::<Base64DecodeError>();
assert_send_sync::<HexDecodeError>();
assert_send_sync::<UrlDecodeError>();
assert_send_sync::<RandomError>();
assert_send_sync::<Timestamp>();
assert_send_sync::<Zeroizing<Vec<u8>>>();
assert_send_sync::<Zeroizing<String>>();
assert_send_sync::<PasswordHash>();
assert_send_sync::<PasswordConfig>();
assert_send_sync::<PasswordError>();
assert_send_sync::<Session>();
assert_send_sync::<SessionConfig>();
assert_send_sync::<SessionError>();
assert_send_sync::<SessionValidation>();
assert_send_sync::<Username>();
assert_send_sync::<UsernameError>();
assert_send_sync::<Credentials>();
assert_send_sync::<StoredCredential>();
assert_send_sync::<InMemoryCredentialStore>();
assert_send_sync::<ApiKey>();
assert_send_sync::<ApiKeyHash>();
assert_send_sync::<ApiKeyError>();
assert_send_sync::<HmacRequestSigner>();
assert_send_sync::<HmacRequestVerifier>();
assert_send_sync::<HmacAuthError>();
assert_send_sync::<BearerError>();
assert_send_sync::<JsonValue>();
assert_send_sync::<JsonParseError>();
assert_send_sync::<JwtAlgorithm>();
assert_send_sync::<JwtHeader>();
assert_send_sync::<JwtHeaderError>();
assert_send_sync::<JwtClaims>();
assert_send_sync::<JwtClaimsError>();
assert_send_sync::<JwtSignatureError>();
assert_send_sync::<JwtEncoder>();
assert_send_sync::<JwtSigningAlgorithm>();
assert_send_sync::<OAuthConfig>();
assert_send_sync::<OAuthConfigBuilder>();
assert_send_sync::<OAuthConfigError>();
assert_send_sync::<PkceChallenge>();
assert_send_sync::<OAuthState>();
assert_send_sync::<AuthorizationRequest>();
assert_send_sync::<TokenExchangeRequest>();
assert_send_sync::<TokenResponse>();
assert_send_sync::<TokenResponseError>();
assert_send_sync::<RefreshRequest>();
assert_send_sync::<RegisteredClient>();
assert_send_sync::<RegisteredClientBuilder>();
assert_send_sync::<ClientType>();
assert_send_sync::<AuthorizeRequest<'static>>();
assert_send_sync::<ValidatedAuthorizeRequest>();
assert_send_sync::<AuthorizeError>();
assert_send_sync::<AuthorizeErrorCode>();
assert_send_sync::<AuthorizeRedirectError>();
assert_send_sync::<DisplayErrorReason>();
assert_send_sync::<ClientAuthResult>();
assert_send_sync::<StoredAuthCode<'static>>();
assert_send_sync::<TokenRequestPresented<'static>>();
assert_send_sync::<CodeRedemptionDenied>();
assert_send_sync::<CodeRedemptionVerdict>();
assert_send_sync::<StoredRefreshToken<'static>>();
assert_send_sync::<RefreshPresented<'static>>();
assert_send_sync::<RefreshDenied>();
assert_send_sync::<RefreshOutcome>();
assert_send_sync::<IntrospectionResponse>();
assert_send_sync::<IdTokenBuilder>();
assert_send_sync::<AuthProviderKind>();
assert_send_sync::<AuthIdentity>();
assert_send_sync::<AuthResult>();
assert_send_sync::<AuthError>();
};
#[cfg(feature = "oidc")]
const _: () = {
const fn assert_send_sync<T: Send + Sync>() {}
assert_send_sync::<OidcDiscovery>();
assert_send_sync::<OidcDiscoveryError>();
assert_send_sync::<IdTokenClaims>();
assert_send_sync::<IdTokenClaimsError>();
assert_send_sync::<IdTokenValidator>();
assert_send_sync::<IdTokenError>();
assert_send_sync::<UserInfo>();
assert_send_sync::<UserInfoError>();
};
#[cfg(feature = "asym-jwt")]
const _: () = {
const fn assert_send_sync<T: Send + Sync>() {}
assert_send_sync::<AsymmetricAlgorithm>();
assert_send_sync::<AsymmetricKeyError>();
assert_send_sync::<AsymmetricSigningKey>();
assert_send_sync::<AsymmetricVerifyingKey>();
assert_send_sync::<Jwk>();
assert_send_sync::<JwkError>();
assert_send_sync::<JwkSet>();
assert_send_sync::<KeyRing>();
};
#[cfg(feature = "saml")]
const _: () = {
const fn assert_send_sync<T: Send + Sync>() {}
assert_send_sync::<SamlConfig>();
assert_send_sync::<SamlConfigError>();
assert_send_sync::<SamlResponse>();
assert_send_sync::<SamlResponseError>();
assert_send_sync::<SamlStatus>();
assert_send_sync::<SamlAssertion>();
assert_send_sync::<SamlSubject>();
assert_send_sync::<SamlConditions>();
assert_send_sync::<SamlAttribute>();
assert_send_sync::<XmlElement>();
assert_send_sync::<XmlParseError>();
};
const _: () = {
const fn assert_send_sync<T: Send + Sync>() {}
assert_send_sync::<BreachResult>();
assert_send_sync::<HibpError>();
assert_send_sync::<HibpPrefix>();
assert_send_sync::<HibpResponse>();
};
const _: () = {
const fn assert_send_sync<T: Send + Sync>() {}
assert_send_sync::<TotpAlgorithm>();
assert_send_sync::<TotpConfig>();
assert_send_sync::<TotpError>();
assert_send_sync::<TotpSecret>();
};
#[cfg(feature = "ssh-keys")]
const _: () = {
const fn assert_send_sync<T: Send + Sync>() {}
assert_send_sync::<SshKeyAlgorithm>();
assert_send_sync::<SshKeyError>();
assert_send_sync::<SshPublicKey>();
};
const _: () = {
const fn assert_send_sync<T: Send + Sync>() {}
assert_send_sync::<SecretBox>();
assert_send_sync::<SecretBoxError>();
};
const _: () = {
const fn assert_send_sync<T: Send + Sync>() {}
assert_send_sync::<WebAuthnError>();
assert_send_sync::<PrfSalt>();
assert_send_sync::<PrfClientResult>();
assert_send_sync::<RelyingParty>();
assert_send_sync::<RelyingPartyBuilder>();
assert_send_sync::<PasskeyCredential>();
assert_send_sync::<InMemoryPasskeyStore>();
assert_send_sync::<InMemoryPasskeyStoreError>();
assert_send_sync::<StoredPasskey>();
assert_send_sync::<RegistrationOutcome>();
assert_send_sync::<AuthenticationOutcome>();
assert_send_sync::<PasskeyUser>();
assert_send_sync::<webauthn::RegistrationChallenge>();
assert_send_sync::<webauthn::AuthenticationChallenge>();
};