rocketmq_auth/credential_rotation/
model.rs1use super::BreakGlassReason;
16use super::CredentialDescriptor;
17use super::CredentialId;
18
19#[derive(Debug, Clone, Copy, PartialEq, Eq)]
21pub enum CredentialVerificationSource {
22 Active,
24 Retiring,
26 BreakGlass,
28}
29
30#[derive(Clone, PartialEq, Eq)]
32pub struct CredentialVerification {
33 pub(super) credential_id: CredentialId,
34 pub(super) generation: u64,
35 pub(super) source: CredentialVerificationSource,
36}
37
38impl std::fmt::Debug for CredentialVerification {
39 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
40 f.debug_struct("CredentialVerification")
41 .field("credential_id", &"[REDACTED]")
42 .field("generation", &self.generation)
43 .field("source", &self.source)
44 .finish()
45 }
46}
47
48impl CredentialVerification {
49 pub fn credential_id(&self) -> &CredentialId {
51 &self.credential_id
52 }
53
54 pub const fn generation(&self) -> u64 {
56 self.generation
57 }
58
59 pub const fn source(&self) -> CredentialVerificationSource {
61 self.source
62 }
63}
64
65#[derive(Clone, PartialEq, Eq)]
67pub struct RetiringCredentialSnapshot {
68 pub(super) credential: CredentialDescriptor,
69 pub(super) accept_until_unix_seconds: u64,
70}
71
72impl std::fmt::Debug for RetiringCredentialSnapshot {
73 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
74 f.debug_struct("RetiringCredentialSnapshot")
75 .field("credential", &"[REDACTED]")
76 .field("accept_until_unix_seconds", &self.accept_until_unix_seconds)
77 .finish()
78 }
79}
80
81impl RetiringCredentialSnapshot {
82 pub fn credential(&self) -> &CredentialDescriptor {
84 &self.credential
85 }
86
87 pub const fn accept_until_unix_seconds(&self) -> u64 {
89 self.accept_until_unix_seconds
90 }
91}
92
93#[derive(Debug, Clone, PartialEq, Eq)]
95pub enum BreakGlassStatus {
96 NotConfigured,
98 Disabled {
100 credential: CredentialDescriptor,
102 },
103 Enabled {
105 credential: CredentialDescriptor,
107 expires_at_unix_seconds: u64,
109 reason: BreakGlassReason,
111 },
112}
113
114#[derive(Debug, Clone, PartialEq, Eq)]
116pub struct CredentialRotationSnapshot {
117 pub(super) generation: u64,
118 pub(super) active: CredentialDescriptor,
119 pub(super) retiring: Option<RetiringCredentialSnapshot>,
120 pub(super) revoked: Vec<CredentialId>,
121 pub(super) break_glass: BreakGlassStatus,
122}
123
124impl CredentialRotationSnapshot {
125 pub const fn generation(&self) -> u64 {
127 self.generation
128 }
129
130 pub fn active(&self) -> &CredentialDescriptor {
132 &self.active
133 }
134
135 pub fn retiring(&self) -> Option<&RetiringCredentialSnapshot> {
137 self.retiring.as_ref()
138 }
139
140 pub fn revoked(&self) -> &[CredentialId] {
142 &self.revoked
143 }
144
145 pub const fn break_glass(&self) -> &BreakGlassStatus {
147 &self.break_glass
148 }
149}