authenticator

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2023 License: Apache-2.0 Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthFromMD

func AuthFromMD(ctx context.Context, scheme string) (string, error)

AuthFromMD is a helper function that extracts an authorization token from a grpc metadata object (same as github.com/grpc-ecosystem/go-grpc-middleware/auth.AuthFromMD)

func StreamServerInterceptor

func StreamServerInterceptor(auth Authenticator, matchers ...selector.Matcher) grpc.StreamServerInterceptor

StreamServerInterceptor returns a new stream server interceptor that authenticates a grpc request If no matchers are provided, the interceptor will attempt to authenticate all requests If matchers are provided, the interceptor will only attempt to authenticate requests if at least one matcher matches

func UnaryServerInterceptor

func UnaryServerInterceptor(auth Authenticator, matchers ...selector.Matcher) grpc.UnaryServerInterceptor

UnaryServerInterceptor returns a new unary server interceptor that authenticates a grpc request If no matchers are provided, the interceptor will attempt to authenticate all requests If matchers are provided, the interceptor will only attempt to authenticate requests if at least one matcher matches

Types

type AuthFunc

type AuthFunc func(ctx context.Context) (context.Context, error)

AuthFunc is a function that authenticates a grpc request

func (AuthFunc) Authenticate

func (f AuthFunc) Authenticate(ctx context.Context) (context.Context, error)

Authenticate implements the Authenticator interface

type Authenticator

type Authenticator interface {
	// Authenticate is a function that authenticates a grpc request
	Authenticate(ctx context.Context) (context.Context, error)
}

Authenticator is an interface that defines a grpc authenticator

func Chain

func Chain(auths ...Authenticator) Authenticator

Chain returns a new Authenticator that chains multiple Authenticators together - the first Authenticator to successfully authenticate the request will be used if all Authenticators fail, the request will be rejected with a status code of codes.Unauthenticated

Jump to

Keyboard shortcuts

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