Skip to main content

authenticate

Function authenticate 

Source
pub async fn authenticate(
    source: &impl TokenSource,
    policy: &TokenPolicy<'_>,
    scopes: &dyn ScopePolicy,
    bearer: &str,
    now: SystemTime,
) -> Result<AuthContext, SourceError>
Expand description

Authenticates a presented bearer token end to end.

TokenSource::claims for the authenticity, then verify for the authorization rules, in that order and with no other path between them.

The token is borrowed and never stored, cloned into a message, or logged — it exists for the length of this call and then only as whatever the authorization server chose to say about it.

§Errors

SourceError::Refused for a token that was refused, and SourceError::Unavailable when the authorization server could not be asked. The two mean different things to a caller and are not merged.