bitwarden_core/auth/
mod.rs

1//! Authentication module
2//!
3//! Contains all the authentication related functionality for registering and logging in.
4
5use thiserror::Error;
6
7use crate::{NotAuthenticatedError, VaultLockedError, WrongPasswordError};
8
9mod access_token;
10pub(super) mod api;
11#[allow(missing_docs)]
12pub mod auth_client;
13mod jwt_token;
14#[allow(missing_docs)]
15pub mod login;
16#[allow(missing_docs)]
17#[cfg(feature = "internal")]
18pub mod password;
19#[allow(missing_docs)]
20#[cfg(feature = "internal")]
21pub mod pin;
22#[allow(missing_docs)]
23pub mod renew;
24pub use access_token::{AccessToken, AccessTokenInvalidError};
25pub use jwt_token::*;
26
27#[cfg(feature = "internal")]
28mod auth_request;
29#[cfg(feature = "internal")]
30pub(crate) use auth_request::{auth_request_decrypt_master_key, auth_request_decrypt_user_key};
31#[cfg(feature = "internal")]
32pub use auth_request::{ApproveAuthRequestError, AuthRequestResponse};
33
34#[cfg(feature = "internal")]
35mod register;
36#[cfg(feature = "internal")]
37pub use register::{RegisterError, RegisterKeyResponse, RegisterRequest};
38
39#[cfg(feature = "internal")]
40mod tde;
41#[cfg(feature = "internal")]
42pub use tde::RegisterTdeKeyResponse;
43#[cfg(feature = "internal")]
44mod key_connector;
45#[cfg(feature = "internal")]
46pub use key_connector::KeyConnectorResponse;
47
48/// Error for authentication related operations
49#[allow(missing_docs)]
50#[derive(Debug, Error)]
51pub enum AuthValidateError {
52    #[error(transparent)]
53    NotAuthenticated(#[from] NotAuthenticatedError),
54    #[error(transparent)]
55    WrongPassword(#[from] WrongPasswordError),
56    #[error(transparent)]
57    VaultLocked(#[from] VaultLockedError),
58    #[error("wrong user key")]
59    WrongUserKey,
60    #[error(transparent)]
61    Crypto(#[from] bitwarden_crypto::CryptoError),
62}