Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/api/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ impl From<CatalogProviderError> for KeystoneApiError {
impl From<IdentityProviderError> for KeystoneApiError {
fn from(value: IdentityProviderError) -> Self {
match value {
IdentityProviderError::AuthenticationInfo { source } => source.into(),
IdentityProviderError::Authentication { source } => source.into(),
IdentityProviderError::UserNotFound(x) => Self::NotFound {
resource: "user".into(),
identifier: x,
Expand Down Expand Up @@ -257,7 +257,7 @@ impl From<RevokeProviderError> for KeystoneApiError {
impl From<TokenProviderError> for KeystoneApiError {
fn from(value: TokenProviderError) -> Self {
match value {
TokenProviderError::AuthenticationInfo(source) => source.into(),
TokenProviderError::Authentication(source) => source.into(),
TokenProviderError::DomainDisabled(x) => Self::NotFound {
resource: "domain".into(),
identifier: x,
Expand Down
18 changes: 9 additions & 9 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,39 +41,39 @@ pub enum KeystoneError {

/// Assignment provider.
#[error(transparent)]
AssignmentError {
AssignmentProvider {
/// The source of the error.
#[from]
source: AssignmentProviderError,
},

/// Catalog provider.
#[error(transparent)]
CatalogError {
CatalogProvider {
/// The source of the error.
#[from]
source: CatalogProviderError,
},

/// Federation provider.
#[error(transparent)]
FederationError {
FederationProvider {
/// The source of the error.
#[from]
source: FederationProviderError,
},

/// Identity provider.
#[error(transparent)]
IdentityError {
IdentityProvider {
/// The source of the error.
#[from]
source: IdentityProviderError,
},

/// Identity mapping provider.
#[error(transparent)]
IdentityMappingError {
IdentityMapping {
/// The source of the error.
#[from]
source: IdentityMappingError,
Expand All @@ -89,7 +89,7 @@ pub enum KeystoneError {

/// Json serialization error.
#[error("json serde error: {}", source)]
JsonError {
Json {
/// The source of the error.
#[from]
source: serde_json::Error,
Expand All @@ -109,7 +109,7 @@ pub enum KeystoneError {

/// Resource provider.
#[error(transparent)]
ResourceError {
ResourceProvider {
/// The source of the error.
#[from]
source: ResourceProviderError,
Expand Down Expand Up @@ -167,12 +167,12 @@ pub enum BuilderError {
UninitializedField(String),
/// Custom validation error
#[error("{0}")]
ValidationError(String),
Validation(String),
}

impl From<String> for BuilderError {
fn from(s: String) -> Self {
Self::ValidationError(s)
Self::Validation(s)
}
}

Expand Down
8 changes: 3 additions & 5 deletions src/identity/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use crate::resource::error::ResourceProviderError;
pub enum IdentityProviderError {
/// Authentication error.
#[error(transparent)]
AuthenticationInfo {
Authentication {
#[from]
source: crate::auth::AuthenticationError,
},
Expand Down Expand Up @@ -109,12 +109,10 @@ impl From<IdentityDatabaseError> for IdentityProviderError {
IdentityDatabaseError::Serde { source } => Self::Serde { source },
IdentityDatabaseError::StructBuilder { source } => Self::StructBuilder { source },
IdentityDatabaseError::PasswordHash { source } => Self::PasswordHash { source },
IdentityDatabaseError::NoPasswordHash(..) => Self::AuthenticationInfo {
IdentityDatabaseError::NoPasswordHash(..) => Self::Authentication {
source: crate::auth::AuthenticationError::UserNameOrPasswordWrong,
},
IdentityDatabaseError::AuthenticationInfo { source } => {
Self::AuthenticationInfo { source }
}
IdentityDatabaseError::AuthenticationInfo { source } => Self::Authentication { source },
_ => Self::Backend { source },
}
}
Expand Down
21 changes: 17 additions & 4 deletions src/token/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ pub enum TokenProviderError {
#[error("application credential is bound to another project")]
ApplicationCredentialScopeMismatch,

/// Assignment provider error.
#[error(transparent)]
AssignmentProvider {
/// The source of the error.
Expand All @@ -57,9 +58,11 @@ pub enum TokenProviderError {
#[error("audit_id must be urlsafe base64 encoded value")]
AuditIdWrongFormat,

/// Authentication error.
#[error(transparent)]
AuthenticationInfo(#[from] crate::auth::AuthenticationError),
Authentication(#[from] crate::auth::AuthenticationError),

/// Base64 Decode error.
#[error("b64 decryption error")]
Base64Decode(#[from] base64::DecodeError),

Expand All @@ -79,10 +82,11 @@ pub enum TokenProviderError {
#[error("token expired")]
Expired,

/// Expired token
/// Expiry calculation error
#[error("token expiry calculation failed")]
ExpiryCalculation,

/// Federated payload missing data error.
#[error("federated payload must contain idp_id and protocol_id")]
FederatedPayloadMissingData,

Expand All @@ -103,6 +107,7 @@ pub enum TokenProviderError {
path: std::path::PathBuf,
},

/// Identity provider error.
#[error(transparent)]
IdentityProvider(#[from] crate::identity::error::IdentityProviderError),

Expand All @@ -113,7 +118,7 @@ pub enum TokenProviderError {
/// Unsupported token version
#[error("token version {0} is not supported")]
InvalidTokenType(u8),
///

/// Unsupported token uuid
#[error("token uuid is not supported")]
InvalidTokenUuid,
Expand Down Expand Up @@ -147,9 +152,11 @@ pub enum TokenProviderError {
#[error("project disabled")]
ProjectDisabled(String),

/// Resource provider error.
#[error(transparent)]
ResourceProvider(#[from] crate::resource::error::ResourceProviderError),

/// Restricted token project scoped error.
#[error("token with restrictions can be only project scoped")]
RestrictedTokenNotProjectScoped,

Expand Down Expand Up @@ -186,33 +193,39 @@ pub enum TokenProviderError {
source: std::num::TryFromIntError,
},

/// Token restriction not found error.
#[error("token restriction {0} not found")]
TokenRestrictionNotFound(String),

/// Revoked token
/// Revoked token error.
#[error("token has been revoked")]
TokenRevoked,

/// Trust provider error.
#[error(transparent)]
TrustProvider(#[from] crate::trust::TrustError),

/// Integer conversion error.
#[error("int parse")]
TryFromIntError(#[from] TryFromIntError),

/// Unsupported authentication methods in token payload.
#[error("unsupported authentication methods {0} in token payload")]
UnsupportedAuthMethods(String),

/// The user is disabled.
#[error("user disabled")]
UserDisabled(String),

/// The user cannot be found error.
#[error("user cannot be found: {0}")]
UserNotFound(String),

/// UUID decryption error.
#[error("uuid decryption error")]
Uuid(#[from] uuid::Error),

/// Validation error.
#[error("Token validation error: {0}")]
Validation(#[from] validator::ValidationErrors),
}
Loading