mirror of
https://github.com/datahub-project/datahub.git
synced 2025-07-06 08:38:41 +00:00
28 lines
679 B
Java
28 lines
679 B
Java
![]() |
package react.auth;
|
||
|
|
||
|
import play.mvc.Http;
|
||
|
import play.mvc.Result;
|
||
|
import play.mvc.Security;
|
||
|
|
||
|
import javax.annotation.Nonnull;
|
||
|
import javax.annotation.Nullable;
|
||
|
|
||
|
import static react.auth.AuthUtils.ACTOR;
|
||
|
|
||
|
/**
|
||
|
* Implementation of base Play Authentication used to determine if a request to a route should be
|
||
|
* authenticated.
|
||
|
*/
|
||
|
public class Authenticator extends Security.Authenticator {
|
||
|
@Override
|
||
|
public String getUsername(@Nonnull Http.Context ctx) {
|
||
|
return AuthUtils.isAuthenticated(ctx) ? ctx.session().get(ACTOR) : null;
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
@Nonnull
|
||
|
public Result onUnauthorized(@Nullable Http.Context ctx) {
|
||
|
return unauthorized();
|
||
|
}
|
||
|
}
|