DVOAuthProvider class

Clients, authorizations, tokens and consents, over one database.

Constructors

DVOAuthProvider({required DVDatabaseAdapter database, required DVApiScopes scopes, DVApiKeys? apiKeys, Duration codeLifetime = const Duration(minutes: 1), Duration accessTokenLifetime = const Duration(hours: 1), Duration refreshTokenLifetime = const Duration(days: 30), DateTime clock()?, Random? random, DVLogger? logger})

Properties

accessTokenLifetime → Duration
final
apiKeys → DVApiKeys?
The keys client credentials are exchanged for. Without them the grant is unsupported_grant_type.
final
codeLifetime → Duration
final
database → DVDatabaseAdapter
final
hashCode → int
The hash code for this object.
no setterinherited
refreshTokenLifetime → Duration
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
scopes → DVApiScopes
final

Methods

approve(DVAuthorizationRequest request, {required String userId, required String tenant}) → Future<DVIssuedAuthorizationCode>
Records userId's consent to request on tenant and issues the code.
authenticate(String accessToken, {String? tenant}) → Future<DVApiPrincipal?>
The principal accessToken authenticates as, or null.
authenticateClient(String clientId, String? secret) → Future<DVOAuthClient>
The client clientId with secret, or a DVOAuthError invalid_client. A public client authenticates with no secret.
clientCredentials({required String clientId, required String clientSecret, List<String>? scopes}) → Future<DVOAuthTokenResponse>
The client_credentials grant: an API key's own id and secret, for a token with at most the key's scopes. No refresh token -- the key is the long-lived credential.
consents(String userId, {required String tenant}) → Future<List<DVOAuthConsent>>
userId's live consents on tenant.
describe(DVAuthorizationRequest request) → List<(String, String)>
The consent screen's lines: each scope with the words its declaration gave it.
ensureSchema() → Future<void>
exchangeCode({required String clientId, required String? clientSecret, required String code, required String redirectUri, required String? codeVerifier}) → Future<DVOAuthTokenResponse>
The authorization_code grant.
findClient(String id) → Future<DVOAuthClient?>
introspect(String token, {String? tenant}) → Future<DVOAuthIntrospection>
RFC 7662 introspection of an access token.
needsConsent(DVAuthorizationRequest request, {required String userId, required String tenant}) → Future<bool>
Whether userId has to be asked, or already consented to every scope of request on tenant.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
refresh({required String clientId, required String? clientSecret, required String refreshToken, List<String>? scopes}) → Future<DVOAuthTokenResponse>
The refresh_token grant. The presented token is spent; a spent one presented again revokes the grant.
registerClient({required String name, required List<String> redirectUris, required List<String> scopes, bool public = false, String? tenant, String? actor}) → Future<DVRegisteredOAuthClient>
Registers a client. A confidential client's secret is returned once.
revokeClient(String id, {String? actor}) → Future<void>
Revokes a client. Its tokens stop on their next use, and it can get no more.
revokeConsent(String userId, String clientId, {required String tenant}) → Future<void>
Withdraws userId's consent for clientId on tenant, and ends every grant it allowed.
revokeToken(String token, {required String clientId, String? clientSecret}) → Future<void>
RFC 7009 revocation. A refresh token ends its whole grant; an access token ends itself. A token that is unknown, or belongs to another client, is ignored without saying so.
toString() → String
A string representation of this object.
inherited
validateAuthorization({required String clientId, required String redirectUri, required List<String> scopes, String? codeChallenge, String? codeChallengeMethod, String? state, String responseType = 'code'}) → Future<DVAuthorizationRequest>
Validates an authorization request before the consent screen is shown.

Operators

operator ==(Object other) → bool
The equality operator.
inherited