#![deny(missing_docs)]
#![forbid(unsafe_code)]
#![warn(clippy::all)]
mod audit;
mod config;
mod coordination;
mod oauth2;
mod passkey;
mod session;
mod storage;
mod userdb;
mod utils;
#[cfg(test)]
mod test_utils;
pub use coordination::{
AuthenticationResponse, CoordinationError, RegistrationMode, RegistrationStartRequest,
get_all_users, get_user, handle_finish_authentication_core, handle_finish_registration_core,
handle_start_authentication_core, handle_start_registration_core, list_credentials_core,
};
pub use coordination::{
DeleteCredentialResponse, delete_oauth2_account_admin, delete_oauth2_account_core,
delete_passkey_credential_admin, delete_passkey_credential_core, delete_user_account,
delete_user_account_admin, fedcm_authorized_core, force_logout_user, get_all_active_sessions,
get_authorized_core, list_accounts_core, post_authorized_core, update_passkey_credential_core,
update_user_account, update_user_admin_status,
};
pub use audit::LoginHistoryEntry;
pub use coordination::{
get_own_login_history, get_own_login_history_with_date_range, get_user_login_history_admin,
query_login_history_admin,
};
pub use config::O2P_ROUTE_PREFIX;
pub use config::PASSKEY_SIGNAL_API_MODE;
pub use config::DEMO_PLACEHOLDER_USER_ID;
pub use config::O2P_DEMO_MODE;
pub use oauth2::{
AuthResponse, FedCMCallbackRequest, FedCMNonceResponse, OAuth2Account, OAuth2Mode, OAuth2State,
Provider, ProviderInfo, ProviderName, ProviderUserId, enabled_providers, get_google_client_id,
is_provider_enabled, prepare_fedcm_nonce, prepare_oauth2_auth_request, provider_info,
};
pub use passkey::{
AuthenticationOptions, AuthenticatorInfo, AuthenticatorResponse, ChallengeId, ChallengeType,
CredentialId, PasskeyCredential, RegisterCredential, RegistrationOptions,
get_authenticator_info, get_authenticator_info_batch, get_related_origin_json,
};
pub use session::{
AuthenticationStatus, CsrfHeaderVerified, CsrfToken, SESSION_COOKIE_NAME, SessionCookie,
SessionError, SessionId, User as SessionUser, UserId, generate_page_session_token,
get_csrf_token_from_session, get_user_and_csrf_token_from_session, get_user_from_session,
is_authenticated_basic, is_authenticated_basic_then_csrf,
is_authenticated_basic_then_user_and_csrf, is_authenticated_strict,
is_authenticated_strict_then_csrf, prepare_logout_response, verify_page_session_token,
};
pub use userdb::User as DbUser;
pub async fn init() -> Result<(), Box<dyn std::error::Error>> {
let _ = *config::O2P_ROUTE_PREFIX;
let _ = *config::PASSKEY_SIGNAL_API_MODE;
let _ = *config::O2P_DEMO_MODE;
session::init();
userdb::init().await?;
oauth2::init().await?;
passkey::init().await?;
audit::init().await?;
Ok(())
}
pub use audit::LoginHistoryError;
pub use audit::cleanup_old_login_history;
pub use audit::spawn_login_history_cleanup;