Skip to main content

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, WrongPasswordError};
8
9mod access_token;
10// API is intentionally not visible outside of `auth` as these should be considered private.
11mod api;
12#[cfg(feature = "internal")]
13pub(crate) use api::response::user_decryption_options_response::UserDecryptionOptionsResponseModel;
14#[allow(missing_docs)]
15pub mod auth_client;
16pub mod auth_tokens;
17mod jwt_token;
18#[allow(missing_docs)]
19pub mod login;
20#[allow(missing_docs)]
21#[cfg(feature = "internal")]
22pub mod password;
23#[allow(missing_docs)]
24#[cfg(feature = "internal")]
25pub mod pin;
26#[doc(hidden)]
27pub mod renew;
28pub use access_token::{AccessToken, AccessTokenInvalidError};
29pub use auth_tokens::{ClientManagedTokenHandler, ClientManagedTokens, TokenHandler};
30pub use jwt_token::*;
31
32#[cfg(feature = "internal")]
33mod auth_request;
34#[cfg(feature = "internal")]
35pub use auth_request::{ApproveAuthRequestError, AuthRequestResponse};
36#[cfg(feature = "internal")]
37pub(crate) use auth_request::{auth_request_decrypt_master_key, auth_request_decrypt_user_key};
38
39#[cfg(feature = "internal")]
40mod register;
41#[cfg(feature = "internal")]
42pub use register::{RegisterError, RegisterKeyResponse, RegisterRequest};
43
44#[cfg(feature = "internal")]
45mod tde;
46#[cfg(feature = "internal")]
47pub use tde::RegisterTdeKeyResponse;
48#[cfg(feature = "internal")]
49mod key_connector;
50#[cfg(feature = "internal")]
51pub use key_connector::KeyConnectorResponse;
52
53/// Error for authentication related operations
54#[allow(missing_docs)]
55#[derive(Debug, Error)]
56#[cfg_attr(feature = "uniffi", derive(uniffi::Error), uniffi(flat_error))]
57pub enum AuthValidateError {
58    #[error(transparent)]
59    NotAuthenticated(#[from] NotAuthenticatedError),
60    #[error(transparent)]
61    WrongPassword(#[from] WrongPasswordError),
62    #[error("wrong user key")]
63    WrongUserKey,
64    #[error(transparent)]
65    Crypto(#[from] bitwarden_crypto::CryptoError),
66}