1use thiserror::Error;
2
3#[derive(Error, Debug)]
4pub enum AuthError {
5 #[error("identity not found: {0}")]
6 IdentityNotFound(String),
7
8 #[error("unauthorized: {0}")]
9 Unauthorized(String),
10
11 #[error("credential expired")]
12 CredentialExpired,
13
14 #[error("credential revoked")]
15 CredentialRevoked,
16
17 #[error("insufficient permissions: required {required:?}, has {has:?}")]
18 InsufficientPermissions {
19 required: Vec<String>,
20 has: Vec<String>,
21 },
22
23 #[error("permission not delegable: {0}")]
24 PermissionNotDelegable(String),
25
26 #[error("session expired")]
27 SessionExpired,
28
29 #[error("domain error: {0}")]
30 Domain(String),
31
32 #[error("auth error: {0}")]
33 Other(String),
34}
35
36impl From<claw10_domain::DomainError> for AuthError {
37 fn from(e: claw10_domain::DomainError) -> Self {
38 AuthError::Domain(e.to_string())
39 }
40}