bitwarden_core/auth/login/
mod.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
pub mod response;

#[cfg(feature = "internal")]
mod prelogin;
#[cfg(feature = "internal")]
pub use prelogin::*;

#[cfg(any(feature = "internal", feature = "secrets"))]
mod password;
#[cfg(feature = "internal")]
pub use password::*;

#[cfg(feature = "internal")]
mod two_factor;
#[cfg(feature = "internal")]
pub use two_factor::*;

#[cfg(feature = "internal")]
mod api_key;
#[cfg(feature = "internal")]
pub use api_key::*;

#[cfg(feature = "internal")]
mod auth_request;
#[cfg(feature = "internal")]
pub use auth_request::*;

#[cfg(feature = "secrets")]
mod access_token;
#[cfg(feature = "secrets")]
pub use access_token::*;

#[derive(Debug, thiserror::Error)]
pub enum LoginError {
    #[error(transparent)]
    Api(#[from] crate::ApiError),
    #[error(transparent)]
    Crypto(#[from] bitwarden_crypto::CryptoError),
    #[error(transparent)]
    Serde(#[from] serde_json::Error),
    #[error(transparent)]
    InvalidBase64(#[from] base64::DecodeError),

    #[error(transparent)]
    MissingField(#[from] crate::MissingFieldError),

    #[error(transparent)]
    JwtTokenParse(#[from] super::JwtTokenParseError),
    #[error("JWT token is missing email")]
    JwtTokenMissingEmail,

    #[error(transparent)]
    Prelogin(#[from] PreloginError),
    #[error(transparent)]
    EncryptionSettings(#[from] crate::client::encryption_settings::EncryptionSettingsError),
    #[error(transparent)]
    AccessTokenInvalid(#[from] super::AccessTokenInvalidError),
    #[error(transparent)]
    NotAuthenticated(#[from] super::NotAuthenticatedError),
    #[cfg(feature = "secrets")]
    #[error(transparent)]
    StateFile(#[from] crate::secrets_manager::state::StateFileError),
    #[error("Error parsing Identity response: {0}")]
    IdentityFail(crate::auth::api::response::IdentityTokenFailResponse),

    #[error("The state file could not be read")]
    InvalidStateFile,
    #[error("Invalid organization id")]
    InvalidOrganizationId,

    #[error("The response received was invalid and could not be processed")]
    InvalidResponse,

    #[error("Auth request was not approved")]
    AuthRequestNotApproved,

    #[error("Failed to authenticate")]
    AuthenticationFailed,
}