Class OAuthServerExtension
java.lang.Object
dev.relism.flash.ext.security.oauthserver.OAuthServerExtension
- All Implemented Interfaces:
dev.relism.flash.ext.security.AuthenticationMechanism,dev.relism.flash.extension.FlashExtension
public final class OAuthServerExtension
extends Object
implements dev.relism.flash.extension.FlashExtension, dev.relism.flash.ext.security.AuthenticationMechanism
An OAuth 2.1 authorization server for the application's own users and resources. A user signs in the
way the application's security chain signs anyone in, consents on the application's page, and the
client receives an RFC 9068 access token for one of the application's resources — which this extension,
as an
AuthenticationMechanism, then authenticates.
app.install(new SecurityExtension().origin("https://app.example").loginPage("/login"))
.install(new OAuthServerExtension("/mcp").store(store).signingKeys(keys));
Authorization code with PKCE S256 (the only grant a user takes part in), refresh tokens that
rotate and revoke their family on reuse, client_credentials for clients the application registers
itself; RFC 8414 metadata, RFC 7591 registration, client ID metadata documents, RFC 8707 resource
indicators, RFC 7009 revocation, RFC 9207 iss in the authorization response. The issuer is the
application's SecurityExtension.origin(Request).
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordA registered client, and its secret — shown this once, never stored. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaccessTokenLifetime(Duration lifetime) Lets client metadata documents live on http and private addresses — for development, never production.dev.relism.flash.ext.security.Principalauthenticate(dev.relism.flash.models.Request req) Only tokens this server issued are this mechanism's: any other bearer is left to the rest of the chain.voidconfigure(dev.relism.flash.extension.FlashRegistrar<?> app, dev.relism.flash.extension.FlashContext ctx) consentPage(String consentPage) The application's page asking a signed-in user to allow a client, sent the authorization request as its query string.static StringA new JWK set forsigningKeys(String), private key included: generate once, keep it secret.refreshTokenLifetime(Duration lifetime) Registers a client from its RFC 7591 metadata — whatREGISTERdoes for a client registering itself, and the only way to aclient_credentialsclient.registration(boolean open) Whether any client may register itself atREGISTER(RFC 7591).List<dev.relism.flash.ext.security.SecurityScheme> schemes()Its issuer is"/": this application, at whatever origin it is reached by.The scopes a client may be granted; any other it asks for is left out of the grant.signingKeys(String jwkSet) The signing keys, as a JWK set whose first key is a private P-256 key — seegenerateSigningKeys().store(OAuthStore store) subjects(Function<dev.relism.flash.ext.security.SecurityIdentity, OAuthSubject> subjects) Whom an authorization names, and what its tokens carry — and who may authorize at all: throw to refuse a caller.
-
Field Details
-
AUTHORIZE
- See Also:
-
TOKEN
- See Also:
-
REGISTER
- See Also:
-
REVOKE
- See Also:
-
JWKS
- See Also:
-
METADATA
- See Also:
-
-
Constructor Details
-
OAuthServerExtension
- Parameters:
resources- the paths tokens may be issued for, as RFC 8707 resources on the application's origin; the first is the audience of a request that names none
-
-
Method Details
-
store
-
signingKeys
The signing keys, as a JWK set whose first key is a private P-256 key — seegenerateSigningKeys(). Unset, a key is generated at boot, and every token dies with the process. -
subjects
public OAuthServerExtension subjects(Function<dev.relism.flash.ext.security.SecurityIdentity, OAuthSubject> subjects) Whom an authorization names, and what its tokens carry — and who may authorize at all: throw to refuse a caller. A credential narrower than its user, like an API key, must not become a token with all the user's rights. Default: the principal's name, no claims, anyone signed in. -
scopes
The scopes a client may be granted; any other it asks for is left out of the grant. Default: none. -
accessTokenLifetime
-
refreshTokenLifetime
-
consentPage
The application's page asking a signed-in user to allow a client, sent the authorization request as its query string. It readsGET /oauth/authorize/requestwith that same query, and posts it back to/oauth/authorizewithconsent=alloworconsent=deny. Default/consent. -
registration
Whether any client may register itself atREGISTER(RFC 7591). Defaulttrue. -
allowLocalClients
Lets client metadata documents live on http and private addresses — for development, never production. -
generateSigningKeys
A new JWK set forsigningKeys(String), private key included: generate once, keep it secret. -
register
Registers a client from its RFC 7591 metadata — whatREGISTERdoes for a client registering itself, and the only way to aclient_credentialsclient. -
configure
public void configure(dev.relism.flash.extension.FlashRegistrar<?> app, dev.relism.flash.extension.FlashContext ctx) - Specified by:
configurein interfacedev.relism.flash.extension.FlashExtension
-
authenticate
public dev.relism.flash.ext.security.Principal authenticate(dev.relism.flash.models.Request req) Only tokens this server issued are this mechanism's: any other bearer is left to the rest of the chain. A token is good only under the resource it was issued for (RFC 8707, RFC 9068 §4): one for/mcpauthenticates nothing outside it.- Specified by:
authenticatein interfacedev.relism.flash.ext.security.AuthenticationMechanism
-
schemes
Its issuer is"/": this application, at whatever origin it is reached by.- Specified by:
schemesin interfacedev.relism.flash.ext.security.AuthenticationMechanism
-