Class AccessControlInterceptor<A extends Identity,B extends AccessController,C extends SecurityContext<A,B>,D extends Exchange<C>>
- Type Parameters:
A- the identity typeB- the access controller typeC- the security context typeD- the exchange type
- All Implemented Interfaces:
ExchangeInterceptor<C,D>
An access control interceptor verifies that the access to a resource is authorized.
This interceptor must be executed after the SecurityInterceptor once the SecurityContext has been created. It is basically used to verify that the requester has access to
the resource being intercepted based on the security context and more specifically the authentication, the identity and the access controller.
- Since:
- 1.5
- Author:
- Jeremy Kuhn
-
Method Summary
Modifier and TypeMethodDescriptionstatic <A extends Identity,B extends AccessController, C extends SecurityContext<A, B>, D extends Exchange<C>>
AccessControlInterceptor<A, B, C, D> Returns an access control interceptor that verifies the requester is anonymous (i.e. not authenticated).static <A extends Identity,B extends AccessController, C extends SecurityContext<A, B>, D extends Exchange<C>>
AccessControlInterceptor<A, B, C, D> Returns an access control interceptor that verifies the requester is authenticated.Intercepts the exchange before the exchange handler is invoked.static <A extends Identity,B extends AccessController, C extends SecurityContext<A, B>, D extends Exchange<C>>
AccessControlInterceptor<A, B, C, D> verify(Function<SecurityContext<A, B>, Mono<Boolean>> accessVerifier) Returns an access control interceptor that uses the specified access verifier to verify access.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.inverno.mod.http.server.ExchangeInterceptor
andThen, compose
-
Method Details
-
anonymous
public static <A extends Identity,B extends AccessController, AccessControlInterceptor<A,C extends SecurityContext<A, B>, D extends Exchange<C>> B, anonymous()C, D> Returns an access control interceptor that verifies the requester is anonymous (i.e. not authenticated).
- Type Parameters:
A- the identity typeB- the access controller typeC- the security context typeD- the exchange type- Returns:
- an access control interceptor
-
authenticated
public static <A extends Identity,B extends AccessController, AccessControlInterceptor<A,C extends SecurityContext<A, B>, D extends Exchange<C>> B, authenticated()C, D> Returns an access control interceptor that verifies the requester is authenticated.
- Type Parameters:
A- the identity typeB- the access controller typeC- the security context typeD- the exchange type- Returns:
- an access control interceptor
-
verify
public static <A extends Identity,B extends AccessController, AccessControlInterceptor<A,C extends SecurityContext<A, B>, D extends Exchange<C>> B, verifyC, D> (Function<SecurityContext<A, B>, Mono<Boolean>> accessVerifier) Returns an access control interceptor that uses the specified access verifier to verify access.
The access verifier shall return false to deny the access to the resource resulting in a
ForbiddenExceptionbeing thrown by the interceptor but it can also throw anUnauthorizedExceptionor aForbiddenExceptiondirectly to get a different behaviour or provide more details about the error (e.g. a message).- Type Parameters:
A- the identity typeB- the access controller typeC- the security context typeD- the exchange type- Parameters:
accessVerifier- an access verifier- Returns:
- an access control interceptor
-
intercept
Description copied from interface:ExchangeInterceptorIntercepts the exchange before the exchange handler is invoked.
- Specified by:
interceptin interfaceExchangeInterceptor<A extends Identity,B extends AccessController> - Parameters:
exchange- the server exchange to handle- Returns:
- a Mono emitting the exchange or an instrumented exchange to continue the exchange handling chain or an empty Mono to stop the exchange handling chain
-