Skip to main content

openstack_sdk_auth_core/
authtoken_scope.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
15//! OpenStack AuthToken Scope handling
16//!
17//! When authenticating with AuthToken user is able to explicitly request scope (authorization)
18//!
19//! - `project` - intention to work with a certain project
20//! - `domain` - intention to work with a certain domain
21//! - `unscoped` - authenticate without any explicit roles
22
23use serde::{Deserialize, Serialize};
24use thiserror::Error;
25
26use crate::{Domain, Project, System};
27
28//use crate::auth::auth_token_endpoint as token_v3;
29
30/// AuthToken (X-Auth-Token) Scope based auth errors
31#[derive(Debug, Error)]
32#[non_exhaustive]
33pub enum AuthTokenScopeError {
34    /// Auth data is missing in the config
35    #[error("Auth data is missing")]
36    MissingAuthData,
37
38    /// Scope cannot be built
39    #[error("Cannot determine authorization scope from config")]
40    MissingScope,
41
42    /// Scope cannot be built
43    #[error(transparent)]
44    //"Cannot determine authorization scope from config")]
45    Builder {
46        #[from]
47        source: crate::BuilderError,
48    },
49}
50
51/// Represents AuthToken authorization scope
52#[derive(Clone, Deserialize, Eq, Hash, PartialEq, Serialize, Debug)]
53#[serde(rename_all = "lowercase")]
54pub enum AuthTokenScope {
55    /// Project
56    Project(Project),
57    /// Domain
58    Domain(Domain),
59    /// System
60    System(System),
61    /// Unscoped
62    Unscoped,
63}