bitwarden_core/auth/login/
mod.rs

1pub mod response;
2
3#[cfg(feature = "internal")]
4mod prelogin;
5#[cfg(feature = "internal")]
6pub use prelogin::*;
7
8#[cfg(any(feature = "internal", feature = "secrets"))]
9mod password;
10#[cfg(any(feature = "internal", feature = "secrets"))]
11pub use password::*;
12
13#[cfg(feature = "internal")]
14mod two_factor;
15#[cfg(feature = "internal")]
16pub use two_factor::*;
17
18#[cfg(feature = "internal")]
19mod api_key;
20#[cfg(feature = "internal")]
21pub use api_key::*;
22
23#[cfg(feature = "internal")]
24mod auth_request;
25#[cfg(feature = "internal")]
26pub use auth_request::*;
27
28#[cfg(feature = "secrets")]
29mod access_token;
30#[cfg(feature = "secrets")]
31pub use access_token::*;
32
33#[derive(Debug, thiserror::Error)]
34pub enum LoginError {
35    #[error(transparent)]
36    Api(#[from] crate::ApiError),
37    #[error(transparent)]
38    Crypto(#[from] bitwarden_crypto::CryptoError),
39    #[error(transparent)]
40    Serde(#[from] serde_json::Error),
41    #[error(transparent)]
42    InvalidBase64(#[from] base64::DecodeError),
43
44    #[error(transparent)]
45    MissingField(#[from] crate::MissingFieldError),
46
47    #[error(transparent)]
48    JwtTokenParse(#[from] super::JwtTokenParseError),
49    #[error("JWT token is missing email")]
50    JwtTokenMissingEmail,
51
52    #[cfg(feature = "internal")]
53    #[error(transparent)]
54    Prelogin(#[from] PreloginError),
55    #[error(transparent)]
56    EncryptionSettings(#[from] crate::client::encryption_settings::EncryptionSettingsError),
57    #[error(transparent)]
58    AccessTokenInvalid(#[from] super::AccessTokenInvalidError),
59    #[error(transparent)]
60    NotAuthenticated(#[from] super::NotAuthenticatedError),
61    #[cfg(feature = "secrets")]
62    #[error(transparent)]
63    StateFile(#[from] crate::secrets_manager::state::StateFileError),
64    #[error("Error parsing Identity response: {0}")]
65    IdentityFail(crate::auth::api::response::IdentityTokenFailResponse),
66
67    #[error("The state file could not be read")]
68    InvalidStateFile,
69    #[error("Invalid organization id")]
70    InvalidOrganizationId,
71
72    #[error("The response received was invalid and could not be processed")]
73    InvalidResponse,
74
75    #[error("Auth request was not approved")]
76    AuthRequestNotApproved,
77
78    #[error("Failed to authenticate")]
79    AuthenticationFailed,
80}