Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not possible to restrict authentication to just methods with authorisation restrictions #12

Open
tazmaniax opened this issue May 12, 2013 · 0 comments
Assignees

Comments

@tazmaniax
Copy link

I have a Play v1.2.5 app that integrates DeadBolt with SecureSocial. I would like to just authorise a specific method so I've annotated the controller with @with(Deadbolt.class) and the specific method with @RoleHolderPresent.

The problem is that in Deadbolt.checkRestrictions(), the call to DEADBOLT_HANDLER.beforeRoleCheck(), which calls back into SecureSocial to authenticate the user, is done before the call to getRestrictionType() which means that authentication is required for methods that are not restricted.

It seems like this could be resolved by swapping the order of these two calls so that the check for a restriction takes place first and then if there is a restriction then to check for an authenticated user, e.g.:

    RestrictionType restrictionType = getRestrictionType();

    if (restrictionType != null && restrictionType != RestrictionType.NONE) {
        DEADBOLT_HANDLER.beforeRoleCheck();

        RoleHolder roleHolder = getRoleHolder();

        if (restrictionType == RestrictionType.DYNAMIC)
        {
            handleDynamicChecks(roleHolder);
        }
        else if (restrictionType == RestrictionType.STATIC)
        {
            handleStaticChecks(roleHolder);
        }
        else if (restrictionType == RestrictionType.BASIC)
        {
            handleRoleHolderPresent(roleHolder);
        }
    }

Can you see a problem with this?

cheers,
Chris

@ghost ghost assigned schaloner Jun 1, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants