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.dev.relism.flash.routing.Middlewareenforce(SecurityPolicy policy, AuthenticationEntryPoint anonymous, List<AuthenticationMechanism> mechanisms) A route onlymechanismsauthenticate: every other credential, the session cookie included, is no credential at all here — a bearer route that must not be reached with a browser's cookie or with another mechanism's token.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.mechanism(AuthenticationMechanism mechanism) origin(dev.relism.flash.models.Request req) The configuredorigin(String), or the onereqnames when none is.Where the application is served, e.g.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.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. Unset: straight to the onlyLoginMethodwhen it is a redirect,/loginotherwise. Set it when the application's page knows ways in the list does not, like a provider picked by email. -
origin
Where the application is served, e.g.https://app.example: what session cookies, sign-in callbacks and token audiences are built from. Unset, each request's ownRequest.origin()is used, which the client chooses — set it wherever that matters, which is every deployment. -
mechanism
-
loginMethod
-
refresher
-
schemes
The schemes of every registered mechanism, in registration order. -
origin
The configuredorigin(String), or the onereqnames when none is. -
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. -
enforce
public dev.relism.flash.routing.Middleware enforce(SecurityPolicy policy, AuthenticationEntryPoint anonymous, List<AuthenticationMechanism> mechanisms) A route onlymechanismsauthenticate: every other credential, the session cookie included, is no credential at all here — a bearer route that must not be reached with a browser's cookie or with another mechanism's token. -
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
-