1use crate::browser::{LogoutBinding, SsoRequestBinding, SsoResponseBinding};
2use crate::model::RelayStateParam;
3
4#[derive(Debug, Clone, Copy, PartialEq, Eq)]
6pub enum ForceAuthn {
7 Required,
9 NotRequired,
11}
12
13impl ForceAuthn {
14 pub(super) fn as_bool(self) -> bool {
15 match self {
16 Self::Required => true,
17 Self::NotRequired => false,
18 }
19 }
20}
21
22#[derive(Debug, Clone)]
24pub struct StartSso {
25 pub(super) binding: SsoRequestBinding,
26 pub(super) response_binding: Option<SsoResponseBinding>,
27 pub(super) relay_state: RelayStateParam,
28 pub(super) force_authn: Option<ForceAuthn>,
29 pub(super) acs_index: Option<u16>,
30}
31
32impl StartSso {
33 pub fn redirect() -> Self {
35 Self::new(SsoRequestBinding::Redirect)
36 }
37
38 pub fn post() -> Self {
40 Self::new(SsoRequestBinding::Post)
41 }
42
43 pub fn simple_sign() -> Self {
45 Self::new(SsoRequestBinding::SimpleSign)
46 }
47
48 fn new(binding: SsoRequestBinding) -> Self {
49 Self {
50 binding,
51 response_binding: None,
52 relay_state: RelayStateParam::absent(),
53 force_authn: None,
54 acs_index: None,
55 }
56 }
57
58 pub fn response_binding(mut self, binding: SsoResponseBinding) -> Self {
60 self.response_binding = Some(binding);
61 self
62 }
63
64 pub fn relay_state(mut self, relay_state: RelayStateParam) -> Self {
66 self.relay_state = relay_state;
67 self
68 }
69
70 pub fn force_authn(mut self, force_authn: ForceAuthn) -> Self {
72 self.force_authn = Some(force_authn);
73 self
74 }
75
76 pub fn assertion_consumer_service_index(mut self, acs_index: u16) -> Self {
78 self.acs_index = Some(acs_index);
79 self
80 }
81}
82
83#[derive(Debug, Clone)]
85pub struct RespondSso {
86 pub(super) binding: SsoResponseBinding,
87 pub(super) relay_state: Option<RelayStateParam>,
88}
89
90impl RespondSso {
91 pub fn post() -> Self {
93 Self::new(SsoResponseBinding::Post)
94 }
95
96 pub fn simple_sign() -> Self {
98 Self::new(SsoResponseBinding::SimpleSign)
99 }
100
101 fn new(binding: SsoResponseBinding) -> Self {
102 Self {
103 binding,
104 relay_state: None,
105 }
106 }
107
108 pub fn relay_state(mut self, relay_state: RelayStateParam) -> Self {
113 self.relay_state = Some(relay_state);
114 self
115 }
116}
117
118#[derive(Debug, Clone, Copy, PartialEq, Eq)]
120pub enum LogoutSigning {
121 FollowLocalPolicy,
123 Sign,
125 DoNotSignForCompatibility,
127}
128
129#[derive(Debug, Clone)]
131pub struct StartSlo {
132 pub(super) binding: LogoutBinding,
133 pub(super) relay_state: RelayStateParam,
134 pub(super) signing: LogoutSigning,
135}
136
137impl StartSlo {
138 pub fn redirect() -> Self {
140 Self::new(LogoutBinding::Redirect)
141 }
142
143 pub fn post() -> Self {
145 Self::new(LogoutBinding::Post)
146 }
147
148 pub fn simple_sign() -> Self {
150 Self::new(LogoutBinding::SimpleSign)
151 }
152
153 fn new(binding: LogoutBinding) -> Self {
154 Self {
155 binding,
156 relay_state: RelayStateParam::absent(),
157 signing: LogoutSigning::FollowLocalPolicy,
158 }
159 }
160
161 pub fn relay_state(mut self, relay_state: RelayStateParam) -> Self {
163 self.relay_state = relay_state;
164 self
165 }
166
167 pub fn signing(mut self, signing: LogoutSigning) -> Self {
169 self.signing = signing;
170 self
171 }
172}
173
174#[derive(Debug, Clone)]
176pub struct RespondSlo {
177 pub(super) binding: LogoutBinding,
178 pub(super) relay_state: Option<RelayStateParam>,
179 pub(super) signing: LogoutSigning,
180}
181
182impl RespondSlo {
183 pub fn redirect() -> Self {
185 Self::new(LogoutBinding::Redirect)
186 }
187
188 pub fn post() -> Self {
190 Self::new(LogoutBinding::Post)
191 }
192
193 pub fn simple_sign() -> Self {
195 Self::new(LogoutBinding::SimpleSign)
196 }
197
198 fn new(binding: LogoutBinding) -> Self {
199 Self {
200 binding,
201 relay_state: None,
202 signing: LogoutSigning::FollowLocalPolicy,
203 }
204 }
205
206 pub fn relay_state(mut self, relay_state: RelayStateParam) -> Self {
211 self.relay_state = Some(relay_state);
212 self
213 }
214
215 pub fn signing(mut self, signing: LogoutSigning) -> Self {
217 self.signing = signing;
218 self
219 }
220}