// gRPC middleware which validates the OIDC token sent in every request.
// This check verifies the id token is valid and then extracts the google specific annotations.
gRPC middleware which validates the OIDC token sent in every request.
This check verifies the id token is valid and then extracts the google specific annotations.
// gRPC middleware which validates the OIDC token sent in every request . // This check verifies the id token is valid and then extracts the google specific annotations .
func authUnaryInterceptor(
	ctx context.Context,
	req interface{},
	info *grpc.UnaryServerInfo,
	handler grpc.UnaryHandler,
) (interface{}, error) {
	glog.V(2).Infof(">> authenticating inbound request")
	md, _ := metadata.FromIncomingContext(ctx)
	if len(md["authorization"]) > 0 {
		reqToken := md["authorization"][0]
		splitToken := strings.Split(reqToken, "Bearer")
		tok := strings.TrimSpace(splitToken[1])
		idDoc, err := verifyGoogleIDToken(ctx, targetAudience, tok)
		if err != nil {
			return nil, grpc.Errorf(codes.Unauthenticated, fmt.Sprintf("Request Token verification failed: %v", err))
		}
		newCtx := context.WithValue(ctx, contextKey("idtoken"), idDoc)
		return handler(newCtx, req)
	}
	return nil, grpc.Errorf(codes.Unauthenticated, "Authorization header not provided")
}
func authUnaryInterceptor ( ctx context . Context , req interface { } , info * grpc . UnaryServerInfo , handler grpc . UnaryHandler , ) ( interface { } , error ) { glog . V ( 2 ) . Infof ( " " ) md , _ := metadata . FromIncomingContext ( ctx ) if len ( md [ " " ] ) > 0 { reqToken := md [ " " ] [ 0 ] splitToken := strings . Split ( reqToken , " " ) tok := strings . TrimSpace ( splitToken [ 1 ] ) idDoc , err := verifyGoogleIDToken ( ctx , targetAudience , tok ) if err != nil { return nil , grpc . Errorf ( codes . Unauthenticated , fmt . Sprintf ( " " , err ) ) } newCtx := context . WithValue ( ctx , contextKey ( " " ) , idDoc ) return handler ( newCtx , req ) } return nil , grpc . Errorf ( codes . Unauthenticated , " " ) }
gRPC middleware which validates the OIDC token sent in every request.
gRPC middleware which validates the OIDC token sent in every request .