Package dev.relism.flash.ext.security
Class SecurityExtension
java.lang.Object
dev.relism.flash.ext.security.SecurityExtension
- All Implemented Interfaces:
dev.relism.flash.extension.FlashExtension
Flash security: the authentication chain, the policies security annotations declare, sessions,
and the
/auth/logout and /auth/methods routes. Mechanisms register through
mechanism(dev.relism.flash.ext.security.AuthenticationMechanism), directly or from their own extensions, and are tried in registration order
before the session cookie.
app.install(new SecurityExtension().users(users).roles(roles))
.install(new OidcExtension(OidcProvider.of("sso", issuer, clientId, secret)));
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final dev.relism.flash.routing.MiddlewareKeyThe node security annotations mount under, for middleware that must run before or after it. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionauthenticate(dev.relism.flash.models.Request req) The caller, ornullwhen no mechanism recognises a credential.voidconfigure(dev.relism.flash.extension.FlashRegistrar<?> app, dev.relism.flash.extension.FlashContext ctx) dev.relism.flash.routing.Middlewareenforce(SecurityPolicy policy) dev.relism.flash.routing.Middlewareenforce(SecurityPolicy policy, AuthenticationEntryPoint anonymous) anonymousanswers a caller without credentials on this route instead of the configured entry point.entryPoint(AuthenticationEntryPoint entryPoint) Replaces the default: a browser is redirected to sign in, anything else gets 401 with every challenge.loginMethod(LoginMethod method) Where a browser signs in, unless the onlyLoginMethodis a redirect it can follow directly.mechanism(AuthenticationMechanism mechanism) The policytype's annotations declare, checked against this configuration — declaring roles without aRoleResolverfails here, at boot.refresher(Class<? extends Principal> type, SessionRefresher refresher) roles(RoleResolver roles) Required byRolesAllowed; a handler that declares roles without one fails the boot.scheme(SecurityScheme scheme) Documents and challenges for a credential beyond the oneAuthenticationMechanism.scheme()names.schemes()The schemes of every registered mechanism, in registration order.sessions(SessionStore sessions) sessionTimeout(Duration sessionTimeout) voidsignIn(dev.relism.flash.models.Request req, dev.relism.flash.models.Response res, Principal principal) Starts a session forprincipallasting the configured timeout.voidsignIn(dev.relism.flash.models.Request req, dev.relism.flash.models.Response res, Principal principal, Instant expiresAt) signOut(dev.relism.flash.models.Request req, dev.relism.flash.models.Response res) Ends the caller's session and returns where the browser goes next.users(UserResolver<?> users) ResolvesSecurityIdentity.user— default: the principal itself.
-
Field Details
-
POLICY
public static final dev.relism.flash.routing.MiddlewareKey POLICYThe node security annotations mount under, for middleware that must run before or after it.
-
-
Constructor Details
-
SecurityExtension
public SecurityExtension()
-
-
Method Details
-
users
ResolvesSecurityIdentity.user— default: the principal itself. -
roles
Required byRolesAllowed; a handler that declares roles without one fails the boot. -
entryPoint
Replaces the default: a browser is redirected to sign in, anything else gets 401 with every challenge. -
sessions
-
sessionTimeout
-
loginPage
Where a browser signs in, unless the onlyLoginMethodis a redirect it can follow directly. -
mechanism
-
scheme
Documents and challenges for a credential beyond the oneAuthenticationMechanism.scheme()names. -
loginMethod
-
refresher
-
schemes
The schemes of every registered mechanism, in registration order. -
authenticate
The caller, ornullwhen no mechanism recognises a credential.- Throws:
AuthenticationFailedException- a mechanism recognised one and rejected it
-
policy
The policytype's annotations declare, checked against this configuration — declaring roles without aRoleResolverfails here, at boot.nullfor no annotations. -
enforce
-
enforce
public dev.relism.flash.routing.Middleware enforce(SecurityPolicy policy, AuthenticationEntryPoint anonymous) anonymousanswers a caller without credentials on this route instead of the configured entry point. -
signIn
public void signIn(dev.relism.flash.models.Request req, dev.relism.flash.models.Response res, Principal principal) Starts a session forprincipallasting the configured timeout. -
signIn
-
signOut
Ends the caller's session and returns where the browser goes next. -
configure
public void configure(dev.relism.flash.extension.FlashRegistrar<?> app, dev.relism.flash.extension.FlashContext ctx) - Specified by:
configurein interfacedev.relism.flash.extension.FlashExtension
-