Skip to content

Commit

Permalink
auth_context: fix ContextWithoutProjects helper
Browse files Browse the repository at this point in the history
There's no need to translate incoming MD to outgoing MD.
Also fixes the comment.

Signed-off-by: Stephan Renatus <[email protected]>
  • Loading branch information
srenatus committed May 20, 2019
1 parent 3ef7ee4 commit 2d08d13
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/grpc/auth_context/auth_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,14 @@ func ProjectsFromMetadata(md metadata.MD) []string {
return ps
}

// ContextWithoutProjects removes previously added projects from the GRPC metadata
// for those system operations that must not be filtered by projects.
// ContextWithoutProjects removes previously any projects from the incoming GRPC
// metadata attached to the context. Following attempts to read projects from
// incoming metadata will yield nothing -- so this can be used in handlers that
// should not do projects filtering, but would do that if the key was present.
func ContextWithoutProjects(ctx context.Context) context.Context {
// This will fail on service start context, so only remove projects if ok.
md, ok := metadata.FromIncomingContext(ctx)
if ok {
delete(md, "projects")
ctx = metadata.NewOutgoingContext(ctx, md)
}
return ctx
}
Expand Down

0 comments on commit 2d08d13

Please sign in to comment.