Search and commands

↑ ↓ to select · Enter to open · Esc to close

Type to search packages.

authz

v1.85.0
google.golang.org/grpc/authz

Documentation

pkg.go.dev ↗

Table of contents

↓ to select · Enter to jump· Shift+Enter for source

15 matches

Top ↑

Package authz exposes methods to manage authorization within gRPC.

Experimental

Notice: This package is EXPERIMENTAL and may be changed or removed in a later release.

Types

FileWatcherInterceptor

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

FileWatcherInterceptor contains details used to make authorization decisions by watching a file path that contains authorization policy in JSON format.

NewFileWatcher

func NewFileWatcher(file string, duration time.Duration) (*FileWatcherInterceptor, error)

NewFileWatcher returns a new FileWatcherInterceptor from a policy file that contains JSON string of authorization policy and a refresh duration to specify the amount of time between policy refreshes.

NewFileWatcherWithOptions

func NewFileWatcherWithOptions(options FileWatcherOptions) (*FileWatcherInterceptor, error)

NewFileWatcherWithOptions returns a new FileWatcherInterceptor from a set of options.

Experimental

Notice: This API is EXPERIMENTAL and may be changed or removed in a later release.

FileWatcherInterceptor.Close

func (i *FileWatcherInterceptor) Close()

Close cleans up resources allocated by the interceptor.

FileWatcherInterceptor.StreamInterceptor

func (i *FileWatcherInterceptor) StreamInterceptor(srv any, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error

StreamInterceptor intercepts incoming Stream RPC requests. Only authorized requests are allowed to pass. Otherwise, an unauthorized error is returned to the client.

FileWatcherInterceptor.UnaryInterceptor

func (i *FileWatcherInterceptor) UnaryInterceptor(ctx context.Context, req any, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (any, error)

UnaryInterceptor intercepts incoming Unary RPC requests. Only authorized requests are allowed to pass. Otherwise, an unauthorized error is returned to the client.

FileWatcherOptions

type FileWatcherOptions struct {
	// PolicyFile contains a JSON string of the authorization policy.
	PolicyFile string
	// RefreshDuration is the delay between policy refreshes.
	RefreshDuration time.Duration
	// OnPolicyUpdate is a callback to be invoked when a policy is
	// loaded/updated. The loaded policy string is passed as an argument.
	//
	// The callback is executed synchronously, so should complete quickly or
	// risk blocking future updates.
	OnPolicyUpdate func(string)
}

FileWatcherOptions contains configuration options for the FileWatcherInterceptor.

Experimental

Notice: This API is EXPERIMENTAL and may be changed or removed in a later release.

StaticInterceptor

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

StaticInterceptor contains engines used to make authorization decisions. It either contains two engines deny engine followed by an allow engine or only one allow engine.

NewStatic

func NewStatic(authzPolicy string) (*StaticInterceptor, error)

NewStatic returns a new StaticInterceptor from a static authorization policy JSON string.

StaticInterceptor.StreamInterceptor

func (i *StaticInterceptor) StreamInterceptor(srv any, ss grpc.ServerStream, _ *grpc.StreamServerInfo, handler grpc.StreamHandler) error

StreamInterceptor intercepts incoming Stream RPC requests. Only authorized requests are allowed to pass. Otherwise, an unauthorized error is returned to the client.

StaticInterceptor.UnaryInterceptor

func (i *StaticInterceptor) UnaryInterceptor(ctx context.Context, req any, _ *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (any, error)

UnaryInterceptor intercepts incoming Unary RPC requests. Only authorized requests are allowed to pass. Otherwise, an unauthorized error is returned to the client.

Dependency graph