auth

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StreamInterceptor

func StreamInterceptor(auth Authenticator) grpc.StreamServerInterceptor

StreamInterceptor returns a grpc.StreamServerInterceptor that performs an authentication check for each request by using Authenticator.Authenticate(ctx context.Context).

func UnaryInterceptor

func UnaryInterceptor(auth Authenticator) grpc.UnaryServerInterceptor

UnaryInterceptor returns a grpc.UnaryServerInterceptor that performs an authentication check for each request by using Authenticator.Authenticate(ctx context.Context).

Types

type Authenticator

type Authenticator interface {
	Authenticate(ctx context.Context) (context.Context, error)
}

Authenticator defines the interface to perform the actual authentication of the request. Implementations should fetch the required data from the context.Context object. GRPC specific data like `metadata` and `peer` is available on the context. Should return a new `context.Context` that is a child of `ctx` or `codes.Unauthenticated` when auth is lacking or `codes.PermissionDenied` when lacking permissions.

type AuthenticatorFunc

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

AuthenticatorFunc defines a pluggable function to perform authentication of requests. Should return a new `context.Context` that is a child of `ctx` or `codes.Unauthenticated` when auth is lacking or `codes.PermissionDenied` when lacking permissions.

func (AuthenticatorFunc) Authenticate

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

Authenticate implements the Authenticator interface

type MultiAuthenticator

type MultiAuthenticator []Authenticator

MultiAuthenticator chains a series of Authenticators, allowing multiple authentication types to be used with a single interceptor.

func (MultiAuthenticator) Authenticate

func (m MultiAuthenticator) Authenticate(ctx context.Context) (context.Context, error)

Authenticate implements the Authenticator interface.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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