-
Notifications
You must be signed in to change notification settings - Fork 434
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
Propagate Authentication to SecurityContextHolder #234
Comments
@markbanierink, would you please post a snippet here how you use |
Sure! Our gRPC service looks pretty much like this: @GRpcService
public class EntityServiceImpl extends EntityServiceGrpc.EntityServiceImplBase {
@Autowired
private DomainService domainService;
@Override
public void doFromRemote(EntityProtos.EntityRequest request, StreamObserver<EntityProtos.EntityResponse> responseObserver) {
var entityA = request.getEntityA();
var valB = domainService.doSomething(entityA);
EntityProtos.Entity respVal = EntityProtos.Entity.newBuilder().setValue(valB).build();
var responseBuilder = EntityProtos.EntityResponse.newBuilder();
responseBuilder.addSomeValue(respVal);
responseObserver.onNext(responseBuilder.build());
responseObserver.onCompleted();
}
} And the domain service: @Component
public class DomainService {
@PreAuthorize("hasPermission(#entityA.id, somePermission)")
public Object doSomething(EntityA entityA) {
// do something after permission was checked
}
} |
Thanks @markbanierink. I've integrated your PR, had to refactor a bit because of merge conflicts. All tests are passing, I'll commit tomorrow. I'll also try to support |
@markbanierink , did you have to add |
Yes, it has to be configured: @Configuration
@EnableGlobalMethodSecurity(prePostEnabled = true)
public class SecurityConfiguration {
// some beans
} |
@markbanierink , as I understand, you don't use |
Euhm.. I'm not sure what you mean, but we do have a configuration for the grpc security too: @Configuration
public class CustomGrpcSecurityConfigurerAdapter extends GrpcSecurityConfigurerAdapter {
@Override
public void configure(GrpcSecurity builder) throws Exception {
builder.authorizeRequests().anyMethod().authenticated();
}
// some more configuration
} But yes, for the rest we only use spring security. |
@markbanierink , I've committed the changes from your PR #233. |
@markbanierink , |
See this discussion
@markbanierink, FYI
The text was updated successfully, but these errors were encountered: