@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 java.lang.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 java.util.Optional<java.lang.String> |
getRedirectUri(io.micronaut.http.HttpRequest<?> request,
boolean forbidden)
Returns the redirection uri.
|
protected io.micronaut.http.MutableHttpResponse<?> |
httpResponseWithUri(java.lang.String uri)
Deprecated.
Use
httpResponseWithUri(URI) instead |
protected io.micronaut.http.MutableHttpResponse<?> |
httpResponseWithUri(java.net.URI location)
Builds a HTTP Response redirection to the supplied location.
|
protected io.micronaut.http.HttpStatus |
redirectionHttpStatus() |
org.reactivestreams.Publisher<io.micronaut.http.MutableHttpResponse<?>> |
reject(io.micronaut.http.HttpRequest<?> request,
boolean forbidden)
Handles rejection of a request.
|
protected boolean |
shouldHandleRequest(io.micronaut.http.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 org.reactivestreams.Publisher<io.micronaut.http.MutableHttpResponse<?>> reject(io.micronaut.http.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(io.micronaut.http.HttpRequest<?> request)
request
- The HTTP Request@Deprecated protected io.micronaut.http.MutableHttpResponse<?> httpResponseWithUri(java.lang.String uri) throws java.net.URISyntaxException
httpResponseWithUri(URI)
insteaduri
- The Uri to redirect tojava.net.URISyntaxException
- if the supplied uri String cannot be used with URI.protected io.micronaut.http.MutableHttpResponse<?> httpResponseWithUri(java.net.URI location)
location
- The Uri to redirect toprotected io.micronaut.http.HttpStatus redirectionHttpStatus()
protected java.util.Optional<java.lang.String> getRedirectUri(io.micronaut.http.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.