use crate::browser::{LogoutBinding, SsoRequestBinding, SsoResponseBinding};
use crate::model::RelayStateParam;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ForceAuthn {
Required,
NotRequired,
}
impl ForceAuthn {
pub(super) fn as_bool(self) -> bool {
match self {
Self::Required => true,
Self::NotRequired => false,
}
}
}
#[derive(Debug, Clone)]
pub struct StartSso {
pub(super) binding: SsoRequestBinding,
pub(super) response_binding: Option<SsoResponseBinding>,
pub(super) relay_state: RelayStateParam,
pub(super) force_authn: Option<ForceAuthn>,
pub(super) acs_index: Option<u16>,
}
impl StartSso {
pub fn redirect() -> Self {
Self::new(SsoRequestBinding::Redirect)
}
pub fn post() -> Self {
Self::new(SsoRequestBinding::Post)
}
pub fn simple_sign() -> Self {
Self::new(SsoRequestBinding::SimpleSign)
}
fn new(binding: SsoRequestBinding) -> Self {
Self {
binding,
response_binding: None,
relay_state: RelayStateParam::absent(),
force_authn: None,
acs_index: None,
}
}
pub fn response_binding(mut self, binding: SsoResponseBinding) -> Self {
self.response_binding = Some(binding);
self
}
pub fn relay_state(mut self, relay_state: RelayStateParam) -> Self {
self.relay_state = relay_state;
self
}
pub fn force_authn(mut self, force_authn: ForceAuthn) -> Self {
self.force_authn = Some(force_authn);
self
}
pub fn assertion_consumer_service_index(mut self, acs_index: u16) -> Self {
self.acs_index = Some(acs_index);
self
}
}
#[derive(Debug, Clone)]
pub struct RespondSso {
pub(super) binding: SsoResponseBinding,
pub(super) relay_state: Option<RelayStateParam>,
}
impl RespondSso {
pub fn post() -> Self {
Self::new(SsoResponseBinding::Post)
}
pub fn simple_sign() -> Self {
Self::new(SsoResponseBinding::SimpleSign)
}
fn new(binding: SsoResponseBinding) -> Self {
Self {
binding,
relay_state: None,
}
}
pub fn relay_state(mut self, relay_state: RelayStateParam) -> Self {
self.relay_state = Some(relay_state);
self
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum LogoutSigning {
FollowLocalPolicy,
Sign,
DoNotSignForCompatibility,
}
#[derive(Debug, Clone)]
pub struct StartSlo {
pub(super) binding: LogoutBinding,
pub(super) relay_state: RelayStateParam,
pub(super) signing: LogoutSigning,
}
impl StartSlo {
pub fn redirect() -> Self {
Self::new(LogoutBinding::Redirect)
}
pub fn post() -> Self {
Self::new(LogoutBinding::Post)
}
pub fn simple_sign() -> Self {
Self::new(LogoutBinding::SimpleSign)
}
fn new(binding: LogoutBinding) -> Self {
Self {
binding,
relay_state: RelayStateParam::absent(),
signing: LogoutSigning::FollowLocalPolicy,
}
}
pub fn relay_state(mut self, relay_state: RelayStateParam) -> Self {
self.relay_state = relay_state;
self
}
pub fn signing(mut self, signing: LogoutSigning) -> Self {
self.signing = signing;
self
}
}
#[derive(Debug, Clone)]
pub struct RespondSlo {
pub(super) binding: LogoutBinding,
pub(super) relay_state: Option<RelayStateParam>,
pub(super) signing: LogoutSigning,
}
impl RespondSlo {
pub fn redirect() -> Self {
Self::new(LogoutBinding::Redirect)
}
pub fn post() -> Self {
Self::new(LogoutBinding::Post)
}
pub fn simple_sign() -> Self {
Self::new(LogoutBinding::SimpleSign)
}
fn new(binding: LogoutBinding) -> Self {
Self {
binding,
relay_state: None,
signing: LogoutSigning::FollowLocalPolicy,
}
}
pub fn relay_state(mut self, relay_state: RelayStateParam) -> Self {
self.relay_state = Some(relay_state);
self
}
pub fn signing(mut self, signing: LogoutSigning) -> Self {
self.signing = signing;
self
}
}