Skip to main content

bitwarden_pam/rotation/
mod.rs

1//! PAM credential rotation operations.
2//!
3//! Credential rotation replaces a managed account's secret on schedule or on demand, writing it
4//! into both the target system and the vault cipher.
5
6use std::sync::Arc;
7
8use bitwarden_core::{FromClient, client::ApiConfigurations, key_management::KeySlotIds};
9use bitwarden_crypto::KeyStore;
10#[cfg(feature = "wasm")]
11use wasm_bindgen::prelude::wasm_bindgen;
12
13mod actions;
14mod claim;
15mod configs;
16mod connectors;
17mod error;
18mod models;
19mod registration;
20mod schedule;
21mod target_systems;
22mod validate;
23
24pub use actions::{RotationConfigActions, rotation_config_actions};
25pub use claim::{SealRejection, VerifiedJob, WorkSnapshot, WorkSnapshotError};
26pub use configs::{
27    RotationConfigCreateRequest, RotationConfigDetailView, RotationConfigSealedFields,
28    RotationConfigView, RotationConfigsClient,
29};
30pub use connectors::{
31    AccessConnector, AccessConnectorDetail, AccessConnectorRegistrationResponse,
32    AccessConnectorsClient,
33};
34pub use error::RotationError;
35pub use models::{
36    AccessConnectorStatus, PasswordPolicy, RotationAttempt, RotationAttemptStatus,
37    RotationFailureCode, RotationJob, RotationJobStatus, RotationSource, RotationSyncState,
38    SessionTerminationOutcome, TargetSystemKind, TargetSystemMethod, TargetSystemStatus,
39};
40pub use schedule::{
41    QuartzSchedulePreset, RotationScheduleClient, is_likely_quartz_cron, preset_for_cron,
42};
43pub use target_systems::{
44    TargetSystemCreateError, TargetSystemCreateRequest, TargetSystemSealedFields, TargetSystemView,
45    TargetSystemsClient,
46};
47pub use validate::RotationValidationError;
48
49/// Entry point for PAM credential rotation.
50#[cfg_attr(feature = "wasm", wasm_bindgen)]
51#[derive(Clone, FromClient)]
52pub struct RotationClient {
53    pub(crate) key_store: KeyStore<KeySlotIds>,
54    pub(crate) api_configurations: Arc<ApiConfigurations>,
55}
56
57#[cfg_attr(feature = "wasm", wasm_bindgen)]
58impl RotationClient {
59    /// Access connector operations.
60    pub fn connectors(&self) -> AccessConnectorsClient {
61        AccessConnectorsClient {
62            key_store: self.key_store.clone(),
63            api_configurations: self.api_configurations.clone(),
64        }
65    }
66
67    /// Target system operations.
68    pub fn target_systems(&self) -> TargetSystemsClient {
69        TargetSystemsClient {
70            key_store: self.key_store.clone(),
71            api_configurations: self.api_configurations.clone(),
72        }
73    }
74
75    /// Managed credential (rotation config) operations.
76    pub fn configs(&self) -> RotationConfigsClient {
77        RotationConfigsClient {
78            key_store: self.key_store.clone(),
79            api_configurations: self.api_configurations.clone(),
80        }
81    }
82
83    /// Quartz cron schedule helpers, with no network access.
84    pub fn schedule(&self) -> RotationScheduleClient {
85        RotationScheduleClient
86    }
87}