Skip to main content

openstack_keystone_core/config/
fernet_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;
18use std::path::PathBuf;
19
20/// Fernet token provider.
21#[derive(Debug, Deserialize, Clone)]
22pub struct FernetTokenProvider {
23    /// Path to the fernet keys.
24    #[serde(default = "default_fernet_key_repository")]
25    pub key_repository: PathBuf,
26    /// Maximal number of fernet keys to keep as active.
27    #[serde(default = "default_fernet_max_active_keys")]
28    pub max_active_keys: usize,
29}
30
31fn default_fernet_key_repository() -> PathBuf {
32    PathBuf::from("/etc/keystone/fernet-keys/")
33}
34
35fn default_fernet_max_active_keys() -> usize {
36    3
37}
38
39impl Default for FernetTokenProvider {
40    fn default() -> Self {
41        Self {
42            key_repository: default_fernet_key_repository(),
43            max_active_keys: default_fernet_max_active_keys(),
44        }
45    }
46}