grpc

package
v2.3.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 21, 2022 License: Apache-2.0 Imports: 17 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CtxWithIncomingToken

func CtxWithIncomingToken(ctx context.Context, token string) context.Context

CtxWithIncomingToken stores token to ctx of response.

func CtxWithToken

func CtxWithToken(ctx context.Context, token string) context.Context

CtxWithToken stores token to ctx of request.

func ErrToStatus

func ErrToStatus(err error) *status.Status

func ForwardErrorf

func ForwardErrorf(code codes.Code, formatter string, args ...interface{}) error

ForwardErrorf tries to unwrap args as error with GRPCStatus() and forward original code and details.

func ForwardFromError

func ForwardFromError(code codes.Code, err error) error

ForwardFromError tries to unwrap err as GRPCStatus() and forward original code and details.

func IsContextCanceled

func IsContextCanceled(err error) bool

func IsContextDeadlineExceeded

func IsContextDeadlineExceeded(err error) bool

func NewOAuthAccess

func NewOAuthAccess(getTokenFunc OAuthGetTokenFunc) credentials.PerRPCCredentials

NewOAuthAccess constructs the PerRPCCredentials using a given token.

func OwnerFromOutgoingTokenMD

func OwnerFromOutgoingTokenMD(ctx context.Context, ownerClaim string) (string, error)

OwnerFromOutgoingTokenMD extracts ownerClaim from token stored by CtxWithToken.

func OwnerFromTokenMD

func OwnerFromTokenMD(ctx context.Context, ownerClaim string) (string, error)

OwnerFromTokenMD is a helper function for extracting the ownerClaim from the :authorization gRPC metadata of the request.

func ParseOwnerFromJwtToken

func ParseOwnerFromJwtToken(ownerClaim, rawJwtToken string) (string, error)

func StreamServerInterceptor

func StreamServerInterceptor(intercept Interceptor) grpc.StreamServerInterceptor

StreamServerInterceptor returns a new unary server interceptors that performs per-request auth.

func StreamServerInterceptorOption

func StreamServerInterceptorOption(intercept Interceptor) grpc.ServerOption

func SubjectFromTokenMD

func SubjectFromTokenMD(ctx context.Context) (string, error)

SubjectFromTokenMD is a helper function for extracting the sub claim from the :authorization gRPC metadata of the request.

func TokenFromMD

func TokenFromMD(ctx context.Context) (string, error)

TokenFromMD is a helper function for extracting the :authorization header from the gRPC metadata of the request.

func TokenFromOutgoingMD

func TokenFromOutgoingMD(ctx context.Context) (string, error)

TokenFromOutgoingMD extracts token stored by CtxWithToken.

func UnaryServerInterceptor

func UnaryServerInterceptor(intercept Interceptor) grpc.UnaryServerInterceptor

UnaryServerInterceptor returns a new unary server interceptors that performs per-request auth.

func UnaryServerInterceptorOption

func UnaryServerInterceptorOption(intercept Interceptor) grpc.ServerOption

Types

type AuthInterceptors

type AuthInterceptors struct {
	// contains filtered or unexported fields
}

func MakeAuthInterceptors

func MakeAuthInterceptors(authFunc Interceptor, whiteListedMethods ...string) AuthInterceptors

func MakeJWTInterceptors

func MakeJWTInterceptors(jwksURL string, tls *tls.Config, claims ClaimsFunc, whiteListedMethods ...string) AuthInterceptors

func (AuthInterceptors) Stream

func (AuthInterceptors) Unary

type Claims

type Claims = interface{ Valid() error }

type ClaimsFunc

type ClaimsFunc = func(ctx context.Context, method string) Claims

type Interceptor

type Interceptor = func(ctx context.Context, method string) (context.Context, error)

func ValidateJWT

func ValidateJWT(jwksURL string, tls *tls.Config, claims ClaimsFunc) Interceptor

func ValidateJWTWithValidator

func ValidateJWTWithValidator(validator Validator, claims ClaimsFunc) Interceptor

type Iterator

type Iterator struct {
	Err error
	// contains filtered or unexported fields
}

func NewIterator

func NewIterator(stream grpc.ClientStream, err error) *Iterator

func (*Iterator) Close

func (it *Iterator) Close()

func (*Iterator) Next

func (it *Iterator) Next(v interface{}) bool

type OAuthGetTokenFunc

type OAuthGetTokenFunc = func(ctx context.Context) (*oauth2.Token, error)

type Validator

type Validator interface {
	ParseWithClaims(token string, claims extJwt.Claims) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL