MCPcopy
hub / github.com/grpc/grpc-go / authz

Function authz

interop/alts/server/server.go:74–88  ·  view source on GitHub ↗

authz shows how to access client information at the server side to perform application-layer authorization checks.

(ctx context.Context, info *tap.Info)

Source from the content-addressed store, hash-verified

72// authz shows how to access client information at the server side to perform
73// application-layer authorization checks.
74func authz(ctx context.Context, info *tap.Info) (context.Context, error) {
75 authInfo, err := alts.AuthInfoFromContext(ctx)
76 if err != nil {
77 return nil, err
78 }
79 // Access all alts.AuthInfo data:
80 logger.Infof("authInfo.ApplicationProtocol() = %v", authInfo.ApplicationProtocol())
81 logger.Infof("authInfo.RecordProtocol() = %v", authInfo.RecordProtocol())
82 logger.Infof("authInfo.SecurityLevel() = %v", authInfo.SecurityLevel())
83 logger.Infof("authInfo.PeerServiceAccount() = %v", authInfo.PeerServiceAccount())
84 logger.Infof("authInfo.LocalServiceAccount() = %v", authInfo.LocalServiceAccount())
85 logger.Infof("authInfo.PeerRPCVersions() = %v", authInfo.PeerRPCVersions())
86 logger.Infof("info.FullMethodName = %v", info.FullMethodName)
87 return ctx, nil
88}

Callers

nothing calls this directly

Calls 8

AuthInfoFromContextFunction · 0.92
InfofMethod · 0.65
ApplicationProtocolMethod · 0.65
RecordProtocolMethod · 0.65
SecurityLevelMethod · 0.65
PeerServiceAccountMethod · 0.65
LocalServiceAccountMethod · 0.65
PeerRPCVersionsMethod · 0.65

Tested by

no test coverage detected