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

Spring Security AccessDecisionManager is deprecated. What's the alternative? #1068

Open
TheMorganHub opened this issue Mar 12, 2024 · 1 comment
Labels
question A question about this library or its usage

Comments

@TheMorganHub
Copy link

TheMorganHub commented Mar 12, 2024

I've successfully implemented security based on roles to my GRPC methods by following the "Server security" tutorial.

Everything works as expected given the following code:

@Configuration
public class GrpcSecurity {

    @Bean
    AuthenticationManager authenticationManager() {
        return authentication -> authentication;
    }

    @Bean
    GrpcAuthenticationReader authenticationReader(ApplicationAuthenticationService awsCognitoApplicationAuthenticationService) {
        //proprietary reader...
    }

    @Bean
    GrpcSecurityMetadataSource grpcSecurityMetadataSource() {
        final ManualGrpcSecurityMetadataSource source = new ManualGrpcSecurityMetadataSource();
        source.set(HelloWorldServiceGrpc.getSayHelloMethod(), AccessPredicate.hasRole("ROLE_ADMIN"));
        source.setDefault(AccessPredicate.denyAll());
        return source;
    }

    @Bean
    AccessDecisionManager accessDecisionManager() {
        final List<AccessDecisionVoter<?>> voters = new ArrayList<>();
        voters.add(new AccessPredicateVoter());
        return new UnanimousBased(voters);
    }
}

However, Intellij points out that AccessDecisionManager, AccessDecisionVoter and UnanimousBased are all deprecated. Spring advises to use AuthorizationManager. In a normal web application, that's easy to do, but how can we make AuthenticationManager work in conjunction GrpcSecurityMetadataSource? If I remove the AccessDecisionManager, authentication/authorisation stops working (as described in GrpcSecurityMetadataSource javadoc).

@TheMorganHub TheMorganHub added the question A question about this library or its usage label Mar 12, 2024
@Saycka
Copy link

Saycka commented Apr 24, 2024

I join the question

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question A question about this library or its usage
Projects
None yet
Development

No branches or pull requests

2 participants