Skip to main content

SamlConfig

Struct SamlConfig 

Source
pub struct SamlConfig {
Show 23 fields pub entity_id: String, pub idp_sso_url: String, pub idp_slo_url: Option<String>, pub idp_entity_id: Option<String>, pub idp_certificate: Option<String>, pub sp_private_key: Option<String>, pub sp_certificate: Option<String>, pub acs_url: String, pub sls_url: Option<String>, pub sso_binding: SamlBinding, pub slo_binding: SamlBinding, pub name_id_format: NameIdFormat, pub authn_context_class: Option<AuthnContextClass>, pub sign_authn_request: bool, pub want_assertions_signed: bool, pub want_assertions_encrypted: bool, pub max_clock_skew: Duration, pub attribute_mapping: HashMap<String, String>, pub role_attribute: Option<String>, pub authority_attribute: Option<String>, pub default_roles: Vec<String>, pub allow_unsolicited_responses: bool, pub session_timeout: Duration,
}
Expand description

SAML Service Provider configuration

Fields§

§entity_id: String

SP Entity ID (unique identifier)

§idp_sso_url: String

IdP SSO URL (where to send AuthnRequest)

§idp_slo_url: Option<String>

IdP Single Logout URL (optional)

§idp_entity_id: Option<String>

IdP Entity ID

§idp_certificate: Option<String>

IdP certificate for signature verification (PEM format)

§sp_private_key: Option<String>

SP private key for signing requests (PEM format)

§sp_certificate: Option<String>

SP certificate (PEM format)

§acs_url: String

Assertion Consumer Service URL

§sls_url: Option<String>

Single Logout Service URL

§sso_binding: SamlBinding

Preferred binding for SSO

§slo_binding: SamlBinding

Preferred binding for SLO

§name_id_format: NameIdFormat

Name ID format to request

§authn_context_class: Option<AuthnContextClass>

Authentication context class to request

§sign_authn_request: bool

Whether to sign AuthnRequest

§want_assertions_signed: bool

Whether to require signed assertions

§want_assertions_encrypted: bool

Whether to require encrypted assertions

§max_clock_skew: Duration

Maximum allowed clock skew

§attribute_mapping: HashMap<String, String>

Attribute mapping (SAML attribute name -> User field)

§role_attribute: Option<String>

Role attribute name

§authority_attribute: Option<String>

Authority attribute name

§default_roles: Vec<String>

Default roles for authenticated users

§allow_unsolicited_responses: bool

Allow unsolicited responses (IdP-initiated SSO)

§session_timeout: Duration

Session timeout

Implementations§

Source§

impl SamlConfig

Source

pub fn new() -> Self

Create a new SAML configuration with minimal required fields

Source

pub fn entity_id(self, entity_id: impl Into<String>) -> Self

Set the SP entity ID

Source

pub fn idp_sso_url(self, url: impl Into<String>) -> Self

Set the IdP SSO URL

Source

pub fn idp_slo_url(self, url: impl Into<String>) -> Self

Set the IdP SLO URL

Source

pub fn idp_entity_id(self, entity_id: impl Into<String>) -> Self

Set the IdP entity ID

Source

pub fn idp_certificate(self, cert: impl Into<String>) -> Self

Set the IdP certificate (PEM format)

Source

pub fn sp_private_key(self, key: impl Into<String>) -> Self

Set the SP private key (PEM format)

Source

pub fn sp_certificate(self, cert: impl Into<String>) -> Self

Set the SP certificate (PEM format)

Source

pub fn acs_url(self, url: impl Into<String>) -> Self

Set the Assertion Consumer Service URL

Source

pub fn assertion_consumer_service_url(self, url: impl Into<String>) -> Self

Alias for acs_url

Source

pub fn sls_url(self, url: impl Into<String>) -> Self

Set the Single Logout Service URL

Source

pub fn sso_binding(self, binding: SamlBinding) -> Self

Set the SSO binding

Source

pub fn slo_binding(self, binding: SamlBinding) -> Self

Set the SLO binding

Source

pub fn name_id_format(self, format: NameIdFormat) -> Self

Set the Name ID format

Source

pub fn authn_context_class(self, class: AuthnContextClass) -> Self

Set the authentication context class

Source

pub fn sign_authn_request(self, sign: bool) -> Self

Set whether to sign AuthnRequest

Source

pub fn want_assertions_signed(self, signed: bool) -> Self

Set whether assertions must be signed

Source

pub fn want_assertions_encrypted(self, encrypted: bool) -> Self

Set whether assertions must be encrypted

Source

pub fn max_clock_skew(self, skew: Duration) -> Self

Set maximum clock skew tolerance

Source

pub fn map_attribute( self, saml_attribute: impl Into<String>, user_field: impl Into<String>, ) -> Self

Add an attribute mapping

Source

pub fn role_attribute(self, attr: impl Into<String>) -> Self

Set the role attribute name

Source

pub fn authority_attribute(self, attr: impl Into<String>) -> Self

Set the authority attribute name

Source

pub fn default_roles(self, roles: Vec<String>) -> Self

Set default roles for authenticated users

Source

pub fn allow_unsolicited_responses(self, allow: bool) -> Self

Set whether to allow unsolicited responses

Source

pub fn session_timeout(self, timeout: Duration) -> Self

Set session timeout

Source

pub fn okta( okta_domain: impl Into<String>, app_id: impl Into<String>, sp_entity_id: impl Into<String>, ) -> Self

Create configuration preset for Okta

Source

pub fn azure_ad( tenant_id: impl Into<String>, _app_id: impl Into<String>, sp_entity_id: impl Into<String>, ) -> Self

Create configuration preset for Azure AD

Source

pub fn google_workspace( sp_entity_id: impl Into<String>, acs_url: impl Into<String>, ) -> Self

Create configuration preset for Google Workspace

Source

pub fn adfs( adfs_host: impl Into<String>, sp_entity_id: impl Into<String>, ) -> Self

Create configuration preset for ADFS

Source

pub fn validate(&self) -> Result<(), SamlError>

Validate the configuration

Trait Implementations§

Source§

impl Clone for SamlConfig

Source§

fn clone(&self) -> SamlConfig

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SamlConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for SamlConfig

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more