openstack_keystone_core/token/
error.rs1use std::num::TryFromIntError;
17
18use thiserror::Error;
19
20use crate::error::BuilderError;
21
22#[derive(Error, Debug)]
24pub enum TokenProviderError {
25 #[error("actor has no roles on scope")]
27 ActorHasNoRolesOnTarget,
28
29 #[error("application credential has expired")]
31 ApplicationCredentialExpired,
32
33 #[error("application credential with id: {0} not found")]
35 ApplicationCredentialNotFound(String),
36
37 #[error(transparent)]
39 ApplicationCredentialProvider {
40 #[from]
42 source: crate::application_credential::error::ApplicationCredentialProviderError,
43 },
44
45 #[error("application credential is bound to another project")]
47 ApplicationCredentialScopeMismatch,
48
49 #[error(transparent)]
51 AssignmentProvider {
52 #[from]
54 source: crate::assignment::error::AssignmentProviderError,
55 },
56
57 #[error("audit_id must be urlsafe base64 encoded value")]
59 AuditIdWrongFormat,
60
61 #[error(transparent)]
63 Authentication(#[from] crate::auth::AuthenticationError),
64
65 #[error("b64 decryption error")]
67 Base64Decode(#[from] base64::DecodeError),
68
69 #[error("{message}")]
71 Conflict { message: String, context: String },
72
73 #[error("domain is disabled")]
78 DomainDisabled(String),
79
80 #[error("backend driver error: {0}")]
82 Driver(String),
83
84 #[error("token expired")]
86 Expired,
87
88 #[error("token expiry calculation failed")]
90 ExpiryCalculation,
91
92 #[error("federated payload must contain idp_id and protocol_id")]
94 FederatedPayloadMissingData,
95
96 #[error("fernet decryption error")]
98 FernetDecryption(#[from] fernet::DecryptionError),
99
100 #[error("no usable fernet keys has been found")]
102 FernetKeysMissing,
103
104 #[error("fernet key read error: {}", source)]
106 FernetKeyRead {
107 source: std::io::Error,
109 path: std::path::PathBuf,
111 },
112
113 #[error(transparent)]
115 IdentityProvider(#[from] crate::identity::error::IdentityProviderError),
116
117 #[error("invalid token error")]
119 InvalidToken,
120
121 #[error("token version {0} is not supported")]
123 InvalidTokenType(u8),
124
125 #[error("token uuid is not supported")]
127 InvalidTokenUuid,
128
129 #[error("token uuid coding {0:?} is not supported")]
131 InvalidTokenUuidMarker(rmp::Marker),
132
133 #[error("io error: {}", source)]
135 Io {
136 #[from]
138 source: std::io::Error,
139 },
140
141 #[error("unix error {source} while {context}")]
143 NixErrno {
144 context: String,
146 source: nix::errno::Errno,
148 },
149
150 #[error(transparent)]
152 Persist(#[from] tempfile::PersistError),
153
154 #[error("project disabled")]
156 ProjectDisabled(String),
157
158 #[error(transparent)]
160 ResourceProvider(#[from] crate::resource::error::ResourceProviderError),
161
162 #[error("token with restrictions can be only project scoped")]
164 RestrictedTokenNotProjectScoped,
165
166 #[error(transparent)]
168 RevokeProvider(#[from] crate::revoke::error::RevokeProviderError),
169
170 #[error("rmp value encoding error")]
172 RmpEncode(String),
173
174 #[error("rmp value error")]
176 RmpValueRead(#[from] rmp::decode::ValueReadError),
177
178 #[error(transparent)]
180 RoleProvider {
181 #[from]
183 source: crate::role::error::RoleProviderError,
184 },
185
186 #[error("scope information missing")]
188 ScopeMissing,
189
190 #[error(transparent)]
192 StructBuilder(#[from] BuilderError),
193
194 #[error("subject information missing")]
196 SubjectMissing,
197
198 #[error("fernet payload timestamp overflow ({value}): {}", source)]
200 TokenTimestampOverflow {
201 value: u64,
203 source: std::num::TryFromIntError,
205 },
206
207 #[error("token restriction {0} not found")]
209 TokenRestrictionNotFound(String),
210
211 #[error("token has been revoked")]
213 TokenRevoked,
214
215 #[error(transparent)]
217 TrustProvider(#[from] crate::trust::TrustProviderError),
218
219 #[error("trustee domain disabled")]
221 TrustorDomainDisabled,
222
223 #[error("int parse")]
225 TryFromIntError(#[from] TryFromIntError),
226
227 #[error("unsupported authentication methods {0} in token payload")]
229 UnsupportedAuthMethods(String),
230
231 #[error("driver `{0}` is not supported for the token restriction provider")]
233 UnsupportedTRDriver(String),
234
235 #[error("user disabled")]
237 UserDisabled(String),
238
239 #[error("user domain disabled")]
241 UserDomainDisabled,
242
243 #[error("the token subject user is not trustee of the trust")]
245 UserIsNotTrustee,
246
247 #[error("user cannot be found: {0}")]
249 UserNotFound(String),
250
251 #[error("uuid decryption error")]
253 Uuid(#[from] uuid::Error),
254
255 #[error("Token validation error: {0}")]
257 Validation(#[from] validator::ValidationErrors),
258}