Skip to main content

openstack_keystone_core/trust/
error.rs

1// Licensed under the Apache License, Version 2.0 (the "License");
2// you may not use this file except in compliance with the License.
3// You may obtain a copy of the License at
4//
5//     http://www.apache.org/licenses/LICENSE-2.0
6//
7// Unless required by applicable law or agreed to in writing, software
8// distributed under the License is distributed on an "AS IS" BASIS,
9// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10// See the License for the specific language governing permissions and
11// limitations under the License.
12//
13// SPDX-License-Identifier: Apache-2.0
14//! # Trust Error
15use thiserror::Error;
16
17use crate::error::BuilderError;
18
19/// Trust extension error.
20#[derive(Error, Debug)]
21pub enum TrustProviderError {
22    /// Supported authentication error.
23    #[error(transparent)]
24    AuthenticationInfo {
25        /// The source of the error.
26        #[from]
27        source: crate::auth::AuthenticationError,
28    },
29
30    /// Conflict.
31    #[error("conflict: {0}")]
32    Conflict(String),
33
34    /// Driver error.
35    #[error("backend driver error: {0}")]
36    Driver(String),
37
38    /// Trust expiration is more than the redelegated trust can provide.
39    #[error("requested expiration is more than the redelegated trust can provide")]
40    ExpirationImpossible,
41
42    /// DateTime parsing error.
43    #[error("error parsing int column as datetime: {expires_at}")]
44    ExpirationDateTimeParse { id: String, expires_at: i64 },
45
46    /// Relegated trust does not allow impersonation.
47    #[error(
48        "impersonation is not allowed because redelegated trust does not specify impersonation"
49    )]
50    RedelegatedImpersonationNotAllowed,
51
52    /// Relegation trust must not add new roles.
53    #[error("some of the requested roles are not in the redelegated trust")]
54    RedelegatedRolesNotAvailable,
55
56    /// Redelegation chain is longer than allowed.
57    #[error("redelegation depth of {length} is out of allowed range [0..{max_depth}]")]
58    RedelegationDeepnessExceed { length: usize, max_depth: usize },
59
60    /// Remaining uses of the trust is exceeded.
61    #[error("remaining uses exceed")]
62    RemainingUsesExceed,
63
64    /// Remaining uses must be unset to redelegate a trust.
65    #[error("remaining uses is set while it must not be set in order to redelegate a trust")]
66    RemainingUsesMustBeUnset,
67
68    /// Role provider error.
69    #[error(transparent)]
70    RoleProvider {
71        /// The source of the error.
72        #[from]
73        source: crate::role::RoleProviderError,
74    },
75
76    /// (de)serialization error.
77    #[error(transparent)]
78    Serde {
79        /// The source of the error.
80        #[from]
81        source: serde_json::Error,
82    },
83
84    /// Structures builder error.
85    #[error(transparent)]
86    StructBuilder {
87        /// The source of the error.
88        #[from]
89        source: BuilderError,
90    },
91
92    /// Unsupported driver.
93    #[error("unsupported driver `{0}` for the trust provider")]
94    UnsupportedDriver(String),
95}