mod challenge;
mod challenge_rate_limit;
mod cookies;
mod errors;
mod openapi;
mod options;
mod response;
mod routes;
mod schema;
mod session;
mod store;
mod webauthn;
pub use errors::PASSKEY_ERROR_CODES;
pub use options::{
AfterAuthenticationVerificationInput, AfterRegistrationVerificationInput,
AuthenticatorAttachment, AuthenticatorSelection, PasskeyAdvancedOptions,
PasskeyAuthenticationOptions, PasskeyAuthenticationRejected, PasskeyChallengeRateLimit,
PasskeyExtensionsInput, PasskeyManagementOptions, PasskeyOptions, PasskeyRateLimit,
PasskeyRegistrationOptions, PasskeyRegistrationUser, PasskeySchemaOptions,
RegistrationWebAuthnOptions, ResidentKeyRequirement, ResolveRegistrationUserInput,
UserVerificationRequirement,
};
pub use store::Passkey;
pub use webauthn::{
PasskeyAuthenticationStart, PasskeyRegistrationStart, VerifiedAuthentication,
VerifiedPasskeyCredential, WebAuthnConfig,
};
#[cfg(feature = "test-util")]
pub use webauthn::{PasskeyWebAuthnBackend, RealPasskeyWebAuthnBackend};
use rustauth_core::plugin::{AuthPlugin, PluginRateLimitRule};
pub const UPSTREAM_PLUGIN_ID: &str = "passkey";
pub const RATE_LIMITED_CEREMONY_PATHS: &[&str] = &[
"/passkey/generate-authenticate-options",
"/passkey/verify-authentication",
"/passkey/generate-register-options",
"/passkey/verify-registration",
];
#[must_use]
pub fn passkey(options: PasskeyOptions) -> AuthPlugin {
let rate_limit_rule = options.rate_limit_rule();
let options = std::sync::Arc::new(options);
let mut plugin = AuthPlugin::new(UPSTREAM_PLUGIN_ID).with_version(env!("CARGO_PKG_VERSION"));
for path in RATE_LIMITED_CEREMONY_PATHS {
plugin = plugin.with_rate_limit(PluginRateLimitRule::new(*path, rate_limit_rule.clone()));
}
for contribution in schema::contributions(&options) {
plugin = plugin.with_schema(contribution);
}
for code in errors::plugin_error_codes() {
plugin = plugin.with_error_code(code);
}
for endpoint in routes::endpoints(options) {
plugin = plugin.with_endpoint(endpoint);
}
plugin
}