AuthInfoFromContext extracts the alts.AuthInfo object from the given context, if it exists. This API should be used by gRPC server RPC handlers to get information about the communicating peer. For client-side, use grpc.Peer() CallOption.
(ctx context.Context)
| 33 | // information about the communicating peer. For client-side, use grpc.Peer() |
| 34 | // CallOption. |
| 35 | func AuthInfoFromContext(ctx context.Context) (AuthInfo, error) { |
| 36 | p, ok := peer.FromContext(ctx) |
| 37 | if !ok { |
| 38 | return nil, errors.New("no Peer found in Context") |
| 39 | } |
| 40 | return AuthInfoFromPeer(p) |
| 41 | } |
| 42 | |
| 43 | // AuthInfoFromPeer extracts the alts.AuthInfo object from the given peer, if it |
| 44 | // exists. This API should be used by gRPC clients after obtaining a peer object |