TokenService

interface TokenService(source)

Access token service that combines generation and verification, i.e., it is suitable to be used in an implementation of an OAuth 2.0 Authorization Server.

Also implements OAuth 2.0 Token Exchange.

Inheritors

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Whether this service can bind a token presented as TokenRequestParameters.subjectToken to the client presenting it, i.e. whether validateAccessToken proves possession of the key that token is bound to.

Link copied to clipboard

Functions

Link copied to clipboard
open suspend fun dpopNonce(): String?
Link copied to clipboard
abstract suspend fun readUserInfo(authorizationHeader: String, request: RequestInfo?): ValidatedAccessToken

Provides information about the access token from authorizationHeader, if it has been issued by generation.

Link copied to clipboard
open suspend fun tokenExchange(request: TokenRequestParameters, expectedResource: String, httpRequest: RequestInfo?, validatedClientKey: JsonWebKey?): KmmResult<TokenResponseParameters>

OAuth 2.0 Token Exchange: Validate the received token from TokenRequestParameters.subjectToken and issue a fresh access token. Callers need to make sure that the client has been authenticated before calling this method.

Link copied to clipboard
open suspend fun validateAccessToken(authorizationHeader: String, httpRequest: RequestInfo?, validatedClientKey: JsonWebKey?): KmmResult<ValidatedAccessToken>

Validates the access token from authorizationHeader and returns what it authorizes. Implementations that issued the token themselves also fill ValidatedAccessToken.userInfoExtended, so callers do not need a second lookup with readUserInfo.

Link copied to clipboard
abstract suspend fun validateTokenForTokenExchange(subjectToken: String, httpRequest: RequestInfo?): KmmResult<ValidatedAccessToken>