Skip to main content

User

Struct User 

Source
pub struct User {
    pub name_id: String,
    pub attributes: Vec<(String, String)>,
    pub session_index: Option<String>,
}
Expand description

The authenticated subject an IdP issues a response for.

Fields§

§name_id: String

<NameID> value.

§attributes: Vec<(String, String)>

Attribute values keyed by their LoginResponseAttribute.value_tag; each fills the {attr<Tag>} placeholder produced for that attribute.

§session_index: Option<String>

SessionIndex for Single Logout requests.

Implementations§

Source§

impl User

Source

pub fn new(name_id: impl Into<String>) -> Self

A subject with just a NameID and no attributes.

Examples found in repository?
examples/raw_compat.rs (line 69)
14fn main() -> Result<(), Box<dyn std::error::Error>> {
15    use saml_rs::constants::signature_algorithm::RSA_SHA256;
16    use saml_rs::raw::metadata::{Endpoint, IdpMetadataConfig, SpMetadataConfig};
17    use saml_rs::raw::{
18        Binding, EntitySetting, HttpRequest, IdentityProvider, LoginResponseOptions,
19        ServiceProvider, User,
20    };
21
22    let privkey = include_str!("../tests/fixtures/key/sp_privkey.pem");
23    let cert = include_str!("../tests/fixtures/key/sp_signing_cert.cer");
24    let signing = || {
25        let mut setting = EntitySetting::default();
26        setting.private_key = Some(privkey.into());
27        setting.signing_cert = Some(cert.into());
28        setting.request_signature_algorithm = RSA_SHA256.into();
29        setting
30    };
31
32    let idp = IdentityProvider::from_config(
33        &IdpMetadataConfig {
34            entity_id: "https://idp.example.com/metadata".into(),
35            signing_certs: vec![cert.into()],
36            want_authn_requests_signed: true,
37            single_sign_on_service: vec![Endpoint::new(
38                Binding::Post,
39                "https://idp.example.com/sso",
40            )],
41            ..Default::default()
42        },
43        signing(),
44    )?;
45    let sp = ServiceProvider::from_config(
46        &SpMetadataConfig {
47            entity_id: "https://sp.example.com/metadata".into(),
48            authn_requests_signed: true,
49            want_assertions_signed: true,
50            signing_certs: vec![cert.into()],
51            assertion_consumer_service: vec![Endpoint::new(
52                Binding::Post,
53                "https://sp.example.com/acs",
54            )],
55            ..Default::default()
56        },
57        signing(),
58    )?;
59
60    let request = sp.create_login_request(&idp, Binding::Post, None)?;
61    let parsed = idp.parse_login_request(
62        &sp,
63        Binding::Post,
64        &HttpRequest::post(vec![("SAMLRequest".into(), request.context.clone())]),
65    )?;
66    let response = idp.create_login_response(
67        &sp,
68        Binding::Post,
69        &User::new("alice@example.com"),
70        &LoginResponseOptions {
71            in_response_to: parsed.extract.get_str("request.id"),
72            ..Default::default()
73        },
74    )?;
75    let result = sp.parse_login_response_with_request_id(
76        &idp,
77        Binding::Post,
78        &HttpRequest::post(vec![("SAMLResponse".into(), response.context)]),
79        &request.id,
80    )?;
81    println!(
82        "samlify-port raw authenticated = {:?}",
83        result.extract.get_str("nameID")
84    );
85    Ok(())
86}

Trait Implementations§

Source§

impl Clone for User

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for User

Source§

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

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

impl Default for User

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl Freeze for User

§

impl RefUnwindSafe for User

§

impl Send for User

§

impl Sync for User

§

impl Unpin for User

§

impl UnsafeUnpin for User

§

impl UnwindSafe for User

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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