pub struct TokenExchangeRequest { /* private fields */ }Expand description
The parameters of one RFC 8693 token exchange request (RFC 8693 §2.1).
Build one with TokenExchangeRequest::new, which takes the two REQUIRED
parameters, then chain the optional ones. Supplying only the subject token
requests an impersonation token; adding
actor_token makes it a delegation
exchange (RFC 8693 §1.1).
Debug redacts the subject and actor tokens so they cannot leak into logs
(#24); their presence is still visible.
use rs_identity_model::{TokenExchangeRequest, TOKEN_TYPE_ACCESS_TOKEN, TOKEN_TYPE_JWT};
// Delegation: an actor acting on behalf of the subject, scoped to one API.
let request = TokenExchangeRequest::new("subject.tok", TOKEN_TYPE_ACCESS_TOKEN)
.actor_token("actor.tok", TOKEN_TYPE_JWT)
.audience("https://api.example.com")
.scope("https://api.example.com/read");Implementations§
Source§impl TokenExchangeRequest
impl TokenExchangeRequest
Sourcepub fn new(
subject_token: impl Into<String>,
subject_token_type: impl Into<String>,
) -> Self
pub fn new( subject_token: impl Into<String>, subject_token_type: impl Into<String>, ) -> Self
Starts an impersonation exchange of subject_token, whose type is named
by subject_token_type — one of the TOKEN_TYPE_URIS (RFC 8693 §3).
Both are REQUIRED (RFC 8693 §2.1).
Sourcepub fn actor_token(
self,
token: impl Into<String>,
token_type: impl Into<String>,
) -> Self
pub fn actor_token( self, token: impl Into<String>, token_type: impl Into<String>, ) -> Self
Attaches the acting party’s token, turning the request into a delegation
exchange (RFC 8693 §1.1, §2.1). token_type is one of the
TOKEN_TYPE_URIS and is REQUIRED whenever an actor token is present.
Both arguments must be non-empty: an empty one is rejected when the exchange is validated, so an accidental empty actor token cannot quietly turn a delegation into an impersonation. Simply do not call this method to request impersonation.
Sourcepub fn requested_token_type(self, uri: impl Into<String>) -> Self
pub fn requested_token_type(self, uri: impl Into<String>) -> Self
Names the desired type of the issued token (RFC 8693 §2.1). The server
MAY issue a different type, which it reports in issued_token_type.
Sourcepub fn scope(self, scope: impl Into<String>) -> Self
pub fn scope(self, scope: impl Into<String>) -> Self
Requests scope, sent as a single space-delimited scope parameter
(RFC 6749 §3.3). When unset, no scope parameter is sent.