@Singleton @Secondary @Replaces(value=HttpStatusCodeRejectionHandler.class) @Requires(beans={UnauthorizedRejectionUriProvider.class,ForbiddenRejectionUriProvider.class,RedirectRejectionHandlerConfiguration.class}) @Requires(property="micronaut.security.redirect.enabled",notEquals="false") public class RedirectRejectionHandler extends Object implements RejectionHandler
UnauthorizedRejectionUriProvider
and ForbiddenRejectionUriProvider
exists provides
a RejectionHandler
implementation which performs redirects.
It can be used for session based authentication flows or Open ID flows.Constructor and Description |
---|
RedirectRejectionHandler(UnauthorizedRejectionUriProvider unauthorizedRejectionUriProvider,
ForbiddenRejectionUriProvider forbiddenRejectionUriProvider,
RedirectRejectionHandlerConfiguration redirectRejectionHandlerConfiguration)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected Optional<String> |
getRedirectUri(HttpRequest<?> request,
boolean forbidden)
Returns the redirection uri.
|
protected MutableHttpResponse<?> |
httpResponseWithUri(String uri)
Builds a HTTP Response redirection to the supplied location.
|
protected HttpStatus |
redirectionHttpStatus() |
Publisher<MutableHttpResponse<?>> |
reject(HttpRequest<?> request,
boolean forbidden)
Handles rejection of a request.
|
protected boolean |
shouldHandleRequest(HttpRequest<?> request)
Decides whether the request should be handled with a redirect.
|
public RedirectRejectionHandler(UnauthorizedRejectionUriProvider unauthorizedRejectionUriProvider, ForbiddenRejectionUriProvider forbiddenRejectionUriProvider, RedirectRejectionHandlerConfiguration redirectRejectionHandlerConfiguration)
unauthorizedRejectionUriProvider
- URI Provider to redirect to if unauthenticatedforbiddenRejectionUriProvider
- URI Provider to redirect to if authenticated but not enough authorization level.redirectRejectionHandlerConfiguration
- Redirect Rejection Handler Configurationpublic Publisher<MutableHttpResponse<?>> reject(HttpRequest<?> request, boolean forbidden)
reject
in interface RejectionHandler
request
- HttpRequest
being processedforbidden
- if true indicates that although the user was authenticated he did not had the necessary access privileges.protected boolean shouldHandleRequest(HttpRequest<?> request)
request
- The HTTP Requestprotected MutableHttpResponse<?> httpResponseWithUri(String uri) throws URISyntaxException
uri
- The Uri to redirect toURISyntaxException
- if the supplied uri String cannot be used with URI.protected HttpStatus redirectionHttpStatus()
protected Optional<String> getRedirectUri(HttpRequest<?> request, boolean forbidden)
request
- HttpRequest
being processedforbidden
- if true indicates that although the user was authenticated he did not had the necessary access privileges.