pub struct IDToken {
pub iss: IssuerIdentifier,
pub sub: SubjectIdentifier,
pub aud: Audience,
pub exp: Expiration,
pub iat: IssuedAt,
pub nonce: Option<Nonce>,
}Fields§
§iss: IssuerIdentifierREQUIRED
Issuer Identifier for the Issuer of the response. The iss value is a case-sensitive URL using the https scheme that contains scheme, host, and optionally, port number and path components and no query or fragment components.
sub: SubjectIdentifierREQUIRED
Subject Identifier. A locally unique and never reassigned identifier within the Issuer for the End-User, which is intended to be consumed by the Client, e.g., 24400320 or AItOawmwtWwcT0k51BayewNvutrJUqsvl6qs7A4. It MUST NOT exceed 255 ASCII RFC20 characters in length. The sub value is a case-sensitive string.
aud: AudienceREQUIRED
Audience(s) that this ID Token is intended for. It MUST contain the OAuth 2.0 client_id of the Relying Party
as an audience value. It MAY also contain identifiers for other audiences. In the general case, the aud value
is an array of case-sensitive strings. In the common special case when there is one audience, the aud value MAY
be a single case-sensitive string.
exp: ExpirationREQUIRED
Expiration time on or after which the ID Token MUST NOT be accepted by the RP when performing authentication with the OP. The processing of this parameter requires that the current date/time MUST be before the expiration date/time listed in the value. Implementers MAY provide for some small leeway, usually no more than a few minutes, to account for clock skew. Its value is a JSON RFC8259 number representing the number of seconds from 1970-01-01T00:00:00Z as measured in UTC until the date/time. See RFC 3339 RFC3339 for details regarding date/times in general and UTC in particular.
NOTE: The ID Token expiration time is unrelated the lifetime of the authenticated session between the RP and the OP.
iat: IssuedAtREQUIRED
Time at which the JWT was issued. Its value is a JSON number representing the number of seconds from 1970-01-01T00:00:00Z as measured in UTC until the date/time.
nonce: Option<Nonce>OPTIONAL
String value used to associate a Client session with an ID Token, and to mitigate replay attacks. The value is passed through unmodified
from the Authentication Request to the ID Token. If present in the ID Token, Clients MUST verify that the nonce Claim Value is equal
to the value of the nonce parameter sent in the Authentication Request. If present in the Authentication Request, Authorization Servers
MUST include a nonce Claim in the ID Token with the Claim Value being the nonce value sent in the Authentication Request.
Authorization Servers SHOULD perform no other processing on nonce values used. The nonce value is a case-sensitive string.
Implementations§
Source§impl IDToken
impl IDToken
Sourcepub fn validate(&self) -> Result<()>
pub fn validate(&self) -> Result<()>
ID Token Validation
Clients MUST validate the ID Token in the Token Response in the following manner:
-
If the ID Token is encrypted, decrypt it using the keys and algorithms that the Client specified during Registration that the OP was to use to encrypt the ID Token. If encryption was negotiated with the OP at Registration time and the ID Token is not encrypted, the RP SHOULD reject it.
-
The Issuer Identifier for the OpenID Provider (which is typically obtained during Discovery) MUST exactly match the value of the
iss(issuer) Claim. -
The Client MUST validate that the
aud(audience) Claim contains itsclient_idvalue registered at the Issuer identified by theiss(issuer) Claim as an audience. Theaud(audience) Claim MAY contain an array with more than one element. The ID Token MUST be rejected if the ID Token does not list the Client as a valid audience, or if it contains additional audiences not trusted by the Client. -
If the implementation is using extensions (which are beyond the scope of this specification) that result in the
azp(authorized party) Claim being present, it SHOULD validate theazpvalue as specified by those extensions. -
This validation MAY include that when an
azp(authorized party) Claim is present, the Client SHOULD verify that itsclient_idis the Claim Value. -
If the ID Token is received via direct communication between the Client and the Token Endpoint (which it is in this flow), the TLS server validation MAY be used to validate the issuer in place of checking the token signature. The Client MUST validate the signature of all other ID Tokens according to JWS using the algorithm specified in the JWT
algHeader Parameter. The Client MUST use the keys provided by the Issuer. -
The
algvalue SHOULD be the default ofRS256or the algorithm sent by the Client in theid_token_signed_response_algparameter during Registration. -
If the JWT
algHeader Parameter uses a MAC based algorithm such asHS256,HS384, orHS512, the octets of the UTF-8 RFC3629 representation of theclient_secretcorresponding to theclient_idcontained in theaud(audience) Claim are used as the key to validate the signature. For MAC based algorithms, the behavior is unspecified if theaudis multi-valued. -
The current time MUST be before the time represented by the
expClaim. -
The
iatClaim can be used to reject tokens that were issued too far away from the current time, limiting the amount of time that nonces need to be stored to prevent attacks. The acceptable range is Client specific. -
If a nonce value was sent in the Authentication Request, a
nonceClaim MUST be present and its value checked to verify that it is the same value as the one that was sent in the Authentication Request. The Client SHOULD check thenoncevalue for replay attacks. The precise method for detecting replay attacks is Client specific. -
If the
acrClaim was requested, the Client SHOULD check that the asserted Claim Value is appropriate. The meaning and processing ofacrClaim Values is out of scope for this specification. -
If the
auth_timeClaim was requested, either through a specific request for this Claim or by using themax_ageparameter, the Client SHOULD check theauth_timeClaim value and request re-authentication if it determines too much time has elapsed since the last End-User authentication.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for IDToken
impl<'de> Deserialize<'de> for IDToken
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for IDToken
impl StructuralPartialEq for IDToken
Auto Trait Implementations§
impl Freeze for IDToken
impl RefUnwindSafe for IDToken
impl Send for IDToken
impl Sync for IDToken
impl Unpin for IDToken
impl UnsafeUnpin for IDToken
impl UnwindSafe for IDToken
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.