Skip to main content

openstack_keystone_core/identity/
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
15use thiserror::Error;
16
17use crate::common::password_hashing::PasswordHashError;
18use crate::error::BuilderError;
19use crate::resource::error::ResourceProviderError;
20
21/// Identity provider error.
22#[derive(Error, Debug)]
23pub enum IdentityProviderError {
24    /// Authentication error.
25    #[error(transparent)]
26    Authentication {
27        #[from]
28        source: crate::auth::AuthenticationError,
29    },
30
31    /// Conflict.
32    #[error("conflict: {0}")]
33    Conflict(String),
34
35    #[error("Date calculation error")]
36    DateError,
37
38    /// Driver error.
39    #[error("backend driver error: {0}")]
40    Driver(String),
41
42    /// The group has not been found.
43    #[error("group {0} not found")]
44    GroupNotFound(String),
45
46    #[error(transparent)]
47    Join {
48        #[from]
49        source: tokio::task::JoinError,
50    },
51
52    #[error("corrupted database entries for user {0}")]
53    MalformedUser(String),
54
55    /// No data for local_user and passwords.
56    #[error("no passwords for the user {0}")]
57    NoPasswordsForUser(String),
58
59    /// Row does not contain password hash.
60    #[error("no passwords hash on the row id: {0}")]
61    NoPasswordHash(String),
62
63    /// No entry in the `user` table for the user.
64    #[error("no entry in the `user` table found for user_id: {0}")]
65    NoMainUserEntry(String),
66
67    /// Password hashing error.
68    #[error("password hashing error")]
69    PasswordHash {
70        #[from]
71        source: PasswordHashError,
72    },
73
74    /// Resource provider error.
75    #[error(transparent)]
76    ResourceProvider {
77        #[from]
78        source: ResourceProviderError,
79    },
80
81    /// (de)serialization error.
82    #[error("data serialization error")]
83    Serde {
84        #[from]
85        source: serde_json::Error,
86    },
87
88    /// Structures builder error.
89    #[error(transparent)]
90    StructBuilder {
91        /// The source of the error.
92        #[from]
93        source: BuilderError,
94    },
95
96    /// Unsupported driver.
97    #[error("unsupported driver `{0}` for the identity provider")]
98    UnsupportedDriver(String),
99
100    #[error("user id must be given")]
101    UserIdMissing,
102
103    /// User ID or Name with Domain must be specified.
104    #[error("either user id or user name with user domain id or name must be given")]
105    UserIdOrNameWithDomain,
106
107    /// The user has not been found.
108    #[error("user {0} not found")]
109    UserNotFound(String),
110
111    /// Request validation error.
112    #[error("request validation error: {}", source)]
113    Validation {
114        /// The source of the error.
115        #[from]
116        source: validator::ValidationErrors,
117    },
118}