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

authz: add additional logs to sdk authz #5094

Merged
merged 8 commits into from Feb 18, 2022
8 changes: 8 additions & 0 deletions authz/sdk_server_interceptors.go
Expand Up @@ -32,6 +32,8 @@ import (
"google.golang.org/grpc/status"
)

const logLevel = 2
ashithasantosh marked this conversation as resolved.
Show resolved Hide resolved

var logger = grpclog.Component("authz")

// StaticInterceptor contains engines used to make authorization decisions. It
Expand Down Expand Up @@ -62,6 +64,9 @@ func (i *StaticInterceptor) UnaryInterceptor(ctx context.Context, req interface{
err := i.engines.IsAuthorized(ctx)
if err != nil {
if status.Code(err) == codes.PermissionDenied {
if logger.V(logLevel) {
logger.Infof("unauthorized RPC request rejected %v", err)
}
return nil, status.Errorf(codes.PermissionDenied, "unauthorized RPC request rejected")
}
return nil, err
Expand All @@ -76,6 +81,9 @@ func (i *StaticInterceptor) StreamInterceptor(srv interface{}, ss grpc.ServerStr
err := i.engines.IsAuthorized(ss.Context())
if err != nil {
if status.Code(err) == codes.PermissionDenied {
if logger.V(logLevel) {
logger.Infof("unauthorized RPC request rejected %v", err)
}
return status.Errorf(codes.PermissionDenied, "unauthorized RPC request rejected")
}
return err
Expand Down