Skip to content

Commit

Permalink
Fix permission name truncation
Browse files Browse the repository at this point in the history
  • Loading branch information
ronenh committed Sep 12, 2024
1 parent 9493a0d commit fc30ca0
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion middleware/grpcz/rebac.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import (
"google.golang.org/protobuf/types/known/structpb"
)

const MaxPermissionLen = 64

type RebacMiddleware struct {
policy *Policy
client AuthorizerClient
Expand Down Expand Up @@ -219,7 +221,11 @@ func (c *RebacMiddleware) resourceContext(ctx context.Context, req interface{})

func permissionFromMethod(ctx context.Context) string {
method, _ := grpc.Method(ctx)
path := strings.ToLower(internal.ToPolicyPath(method)[:64])

path := strings.ToLower(internal.ToPolicyPath(method))
if len(path) > MaxPermissionLen {
path = path[:MaxPermissionLen]
}

return path
}
Expand Down

0 comments on commit fc30ca0

Please sign in to comment.