public class RequiresAuthenticationAction
extends play.mvc.Action<play.mvc.Result>
This action checks if the user is not authenticated and starts the authentication process if necessary.
It handles both statefull (default) or stateless resources by delegating to a pac4j client.
The filter also handles basic authorization based on two parameters: requireAnyRole and requireAllRoles.
| Constructor and Description |
|---|
RequiresAuthenticationAction() |
| Modifier and Type | Method and Description |
|---|---|
protected play.libs.F.Promise<org.pac4j.core.profile.CommonProfile> |
authenticate(ActionContext actionContext)
Authenticates the current request by getting the credentials and the corresponding user profile.
|
protected play.libs.F.Promise<play.mvc.Result> |
authenticationFailure(ActionContext actionContext)
Default authentication failure strategy which generates an unauthorized page if stateless web service
or redirect to the authentication provider after saving the original url.
|
protected play.libs.F.Promise<play.mvc.Result> |
authenticationSuccess(org.pac4j.core.profile.CommonProfile profile,
ActionContext actionContext)
Default authentication success strategy which forward to the next action if the user
has access or returns an access denied error otherwise.
|
play.libs.F.Promise<play.mvc.Result> |
call(play.mvc.Http.Context ctx)
Authentication algorithm.
|
protected boolean |
hasAccess(org.pac4j.core.profile.CommonProfile profile,
ActionContext actionContext)
Returns true if the user defined by the profile has access to the underlying resource
depending on the requireAnyRole and requireAllRoles fields.
|
protected boolean |
isAjaxRequest(ActionContext actionContext)
Is it a request Ajax?
|
protected boolean |
isStateless(ActionContext actionContext)
Is it a stateless authentication flow?
|
protected String |
retrieveOriginalUrl(ActionContext actionContext)
Retrieve the requested url from the session.
|
protected play.libs.F.Promise<org.pac4j.core.profile.CommonProfile> |
retrieveUserProfile(ActionContext actionContext)
Retrieve user profile either by looking in the session or trying to authenticate directly
if stateless web service.
|
protected void |
saveOriginalUrl(ActionContext actionContext)
Save the requested url in session if the request is not Ajax.
|
protected void |
saveUserProfile(org.pac4j.core.profile.CommonProfile profile,
ActionContext actionContext)
Save the user profile in session or attach it to the request if stateless web service.
|
badRequest, badRequest, badRequest, badRequest, badRequest, badRequest, badRequest, badRequest, badRequest, badRequest, badRequest, badRequest, badRequest, badRequest, badRequest, created, created, created, created, created, created, created, created, created, created, created, created, created, created, created, forbidden, forbidden, forbidden, forbidden, forbidden, forbidden, forbidden, forbidden, forbidden, forbidden, forbidden, forbidden, forbidden, forbidden, forbidden, found, found, internalServerError, internalServerError, internalServerError, internalServerError, internalServerError, internalServerError, internalServerError, internalServerError, internalServerError, internalServerError, internalServerError, internalServerError, internalServerError, internalServerError, internalServerError, movedPermanently, movedPermanently, noContent, notFound, notFound, notFound, notFound, notFound, notFound, notFound, notFound, notFound, notFound, notFound, notFound, notFound, notFound, notFound, ok, ok, ok, ok, ok, ok, ok, ok, ok, ok, ok, ok, ok, ok, ok, redirect, redirect, seeOther, seeOther, status, status, status, status, status, status, status, status, status, status, status, status, status, temporaryRedirect, temporaryRedirect, unauthorized, unauthorized, unauthorized, unauthorized, unauthorized, unauthorized, unauthorized, unauthorized, unauthorized, unauthorized, unauthorized, unauthorized, unauthorized, unauthorized, unauthorizedpublic play.libs.F.Promise<play.mvc.Result> call(play.mvc.Http.Context ctx)
call in class play.mvc.Action<play.mvc.Result>protected play.libs.F.Promise<org.pac4j.core.profile.CommonProfile> retrieveUserProfile(ActionContext actionContext)
actionContext - protected play.libs.F.Promise<play.mvc.Result> authenticationFailure(ActionContext actionContext)
actionContext - protected void saveUserProfile(org.pac4j.core.profile.CommonProfile profile,
ActionContext actionContext)
profile - actionContext - protected play.libs.F.Promise<play.mvc.Result> authenticationSuccess(org.pac4j.core.profile.CommonProfile profile,
ActionContext actionContext)
throws Throwable
profile - actionContext - Throwableprotected play.libs.F.Promise<org.pac4j.core.profile.CommonProfile> authenticate(ActionContext actionContext)
actionContext - protected boolean hasAccess(org.pac4j.core.profile.CommonProfile profile,
ActionContext actionContext)
profile - actionContext - protected void saveOriginalUrl(ActionContext actionContext)
actionContext - protected String retrieveOriginalUrl(ActionContext actionContext)
actionContext - protected boolean isAjaxRequest(ActionContext actionContext)
actionContext - protected boolean isStateless(ActionContext actionContext)
actionContext - Copyright © 2015. All Rights Reserved.