public interface AuthModule
authenticateHttp(ChannelHandlerContext, HttpRequest) is called at the reception of the http request and
returns an authentication token that is used later on to check for privileges and roles.
Note that while the authenticateHttp(ChannelHandlerContext, HttpRequest) method is asynchronous, the other
methods are supposed to return fast, so the information about the user privileges has to be cached.
For the short lived REST requests the privilege check follows in quick succesion the authenticate call. For the
websocket, however the check privilege it can come a long time after the authenticate so in case the token expires, a
preemptive renewal strategy has to be implemented.| Modifier and Type | Method and Description |
|---|---|
CompletableFuture<AuthenticationToken> |
authenticateHttp(io.netty.channel.ChannelHandlerContext ctx,
io.netty.handler.codec.http.HttpRequest req)
Authenticate the request and return a CompletableFuture to indicate the completion.
|
String[] |
getRoles(AuthenticationToken authenticationToken)
Get the list of roles of the user.
|
User |
getUser(AuthenticationToken authToken)
returns the user authenticated by the token
|
boolean |
hasPrivilege(AuthenticationToken authenticationToken,
PrivilegeType type,
String privilege) |
boolean |
hasRole(AuthenticationToken authenticationToken,
String role) |
CompletableFuture<AuthenticationToken> authenticateHttp(io.netty.channel.ChannelHandlerContext ctx, io.netty.handler.codec.http.HttpRequest req)
ctx - req - String[] getRoles(AuthenticationToken authenticationToken) throws InvalidAuthenticationToken
authenticationToken - InvalidAuthenticationToken - thrown in case the authentication token is not (anymore) validboolean hasRole(AuthenticationToken authenticationToken, String role) throws InvalidAuthenticationToken
authenticationToken - role - InvalidAuthenticationToken - thrown in case the authentication token is not (anymore) validboolean hasPrivilege(AuthenticationToken authenticationToken, PrivilegeType type, String privilege) throws InvalidAuthenticationToken
authenticationToken - type - privilege - InvalidAuthenticationToken - thrown in case the authentication token is not (anymore) validUser getUser(AuthenticationToken authToken)
authToken - Copyright © 2018 Space Applications Services. All rights reserved.