Skip to main content

UserClaims

Struct UserClaims 

Source
pub struct UserClaims {
Show 21 fields pub sub: String, pub name: Option<String>, pub given_name: Option<String>, pub family_name: Option<String>, pub middle_name: Option<String>, pub nickname: Option<String>, pub preferred_username: Option<String>, pub profile: Option<String>, pub picture: Option<String>, pub website: Option<String>, pub gender: Option<String>, pub birthdate: Option<String>, pub zoneinfo: Option<String>, pub locale: Option<String>, pub updated_at: Option<i64>, pub email: Option<String>, pub email_verified: Option<bool>, pub phone_number: Option<String>, pub phone_number_verified: Option<bool>, pub address: Option<AddressClaim>, pub custom: HashMap<String, Value>,
}
Expand description

Standard OpenID Connect user claims.

These claims describe the authenticated user and are included in ID tokens and returned from the userinfo endpoint.

Fields§

§sub: String

Subject identifier (required, unique user ID).

§name: Option<String>

User’s full name.

§given_name: Option<String>

User’s given/first name.

§family_name: Option<String>

User’s family/last name.

§middle_name: Option<String>

User’s middle name.

§nickname: Option<String>

User’s nickname/username.

§preferred_username: Option<String>

User’s preferred username.

§profile: Option<String>

URL of user’s profile page.

§picture: Option<String>

URL of user’s profile picture.

§website: Option<String>

URL of user’s website.

§gender: Option<String>

User’s gender.

§birthdate: Option<String>

User’s birthday (ISO 8601 date).

§zoneinfo: Option<String>

User’s timezone (IANA timezone string).

§locale: Option<String>

User’s locale (BCP47 language tag).

§updated_at: Option<i64>

Time the user’s info was last updated (Unix timestamp).

§email: Option<String>

User’s email address.

§email_verified: Option<bool>

Whether the email has been verified.

§phone_number: Option<String>

User’s phone number.

§phone_number_verified: Option<bool>

Whether the phone number has been verified.

§address: Option<AddressClaim>

User’s address (JSON object).

§custom: HashMap<String, Value>

Additional custom claims.

Implementations§

Source§

impl UserClaims

Source

pub fn new(sub: impl Into<String>) -> UserClaims

Creates new user claims with the given subject.

Source

pub fn with_name(self, name: impl Into<String>) -> UserClaims

Sets the user’s full name.

Source

pub fn with_email(self, email: impl Into<String>) -> UserClaims

Sets the user’s email.

Source

pub fn with_email_verified(self, verified: bool) -> UserClaims

Sets whether the email is verified.

Source

pub fn with_preferred_username(self, username: impl Into<String>) -> UserClaims

Sets the user’s preferred username.

Source

pub fn with_picture(self, url: impl Into<String>) -> UserClaims

Sets the user’s profile picture URL.

Source

pub fn with_given_name(self, name: impl Into<String>) -> UserClaims

Sets the user’s given name.

Source

pub fn with_family_name(self, name: impl Into<String>) -> UserClaims

Sets the user’s family name.

Source

pub fn with_phone_number(self, phone: impl Into<String>) -> UserClaims

Sets the user’s phone number.

Source

pub fn with_updated_at(self, timestamp: i64) -> UserClaims

Sets the updated_at timestamp.

Source

pub fn with_custom(self, key: impl Into<String>, value: Value) -> UserClaims

Adds a custom claim.

Source

pub fn filter_by_scopes(&self, scopes: &[String]) -> UserClaims

Filters claims based on requested scopes.

Only returns claims that are allowed by the given scopes.

Trait Implementations§

Source§

impl Clone for UserClaims

Source§

fn clone(&self) -> UserClaims

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 UserClaims

Source§

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

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

impl Default for UserClaims

Source§

fn default() -> UserClaims

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

impl<'de> Deserialize<'de> for UserClaims

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<UserClaims, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for UserClaims

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. 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> 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: NoopSpan) -> Self

Instruments this future with a span (no-op when disabled).
Source§

fn in_current_span(self) -> Self

Instruments this future with the current span (no-op when disabled).
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> 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<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
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,