openstack_keystone_core/config/token.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//! # Keystone configuration
15//!
16//! Parsing of the Keystone configuration file implementation.
17use serde::Deserialize;
18
19/// Token provider.
20#[derive(Debug, Deserialize, Clone)]
21pub struct TokenProvider {
22 /// Token provider driver.
23 #[serde(default)]
24 pub provider: TokenProviderDriver,
25 /// The amount of time that a token should remain valid (in seconds).
26 /// Drastically reducing this value may break "long-running" operations
27 /// that involve multiple services to coordinate together, and will
28 /// force users to authenticate with keystone more frequently. Drastically
29 /// increasing this value will increase the number of tokens that will be
30 /// simultaneously valid. Keystone tokens are also bearer tokens, so a
31 /// shorter duration will also reduce the potential security impact of a
32 /// compromised token.
33 #[serde(default = "default_token_expiration")]
34 pub expiration: usize,
35}
36
37fn default_token_expiration() -> usize {
38 3600
39}
40
41impl Default for TokenProvider {
42 fn default() -> Self {
43 Self {
44 provider: TokenProviderDriver::Fernet,
45 expiration: default_token_expiration(),
46 }
47 }
48}
49
50/// Token provider driver.
51#[derive(Debug, Default, Deserialize, Clone)]
52pub enum TokenProviderDriver {
53 /// Fernet.
54 #[default]
55 #[serde(rename = "fernet")]
56 Fernet,
57}