service

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2023 License: MIT Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AccountSecretFromContext

func AccountSecretFromContext(ctx context.Context) *secret.Info

func ComponentNameFromContext

func ComponentNameFromContext(ctx context.Context) string

func ContextWithComponentName

func ContextWithComponentName(ctx context.Context, component string) context.Context

func StreamServerInterceptor

func StreamServerInterceptor(v Authenticator) grpc.StreamServerInterceptor

StreamServerInterceptor returns a new streaming server interceptor that authenticates incoming messages.

The stage at which unauthenticated messages will be rejected with `PermissionDenied` varies based on the type of the RPC. For `ServerStream` (1:m) requests, it will happen before reaching any user space handlers. For `ClientStream` (n:1) or `BidiStream` (n:m) RPCs, the messages will be rejected on calls to `stream.Recv()`.

func UnaryServerInterceptor

func UnaryServerInterceptor(v Authenticator) grpc.UnaryServerInterceptor

UnaryServerInterceptor returns a new unary server interceptor that authenticates incoming messages.

Invalid messages will be rejected with `PermissionDenied` before reaching any userspace handlers.

Types

type Authenticator

type Authenticator interface {
	// ServiceComponentName returns the component name implements the service method.
	ServiceComponentName(serviceMethod string) string

	// RegisterServiceSubjects registers required method subjects of the service.
	// The map key of the parameter is the full url path of the method.
	RegisterServiceSubjects(component string, serviceMethodSubjects map[string][]permission.Subject, serviceMethodRoles map[string][]string)

	// Authenticate a request specified by the full url path of the method.
	Authenticate(ctx context.Context, serviceMethod string) (*secret.Info, error)
}

Authenticator interface.

type Implementor

type Implementor interface {
	// Context returns the service context.
	Context() context.Context

	// UnaryInterceptor returns the unary server interceptor for local gateway handler server.
	UnaryInterceptor() grpc.UnaryServerInterceptor

	// StreamInterceptor returns the stream server interceptor for local gateway handler server.
	StreamInterceptor() grpc.StreamServerInterceptor

	// GetGRPCServer returns gRPC server of the specified visible scope.
	GetGRPCServer(scope permission.VisibleScope) []*grpc.Server

	// GetGatewayMux returns gateway mux of the specified visible scope.
	GetGatewayMux(scope permission.VisibleScope) []*runtime.ServeMux
}

Implementor interface.

Jump to

Keyboard shortcuts

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