grpc

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthnBypasswInterceptor

func AuthnBypasswInterceptor() grpc.UnaryServerInterceptor

AuthnBypasswInterceptor 是一个 gRPC 拦截器,模拟所有请求都通过认证。

func AuthnInterceptor

func AuthnInterceptor(retriever UserRetriever) grpc.UnaryServerInterceptor

AuthnInterceptor 是一个 gRPC 拦截器,用于进行认证.

func AuthzInterceptor

func AuthzInterceptor(authorizer Authorizer) grpc.UnaryServerInterceptor

AuthzInterceptor 是一个 gRPC 拦截器,用于进行请求授权.

func DefaulterInterceptor

func DefaulterInterceptor() grpc.UnaryServerInterceptor

DefaulterInterceptor 是一个 gRPC 拦截器,用于对请求进行默认值设置.

func RequestIDInterceptor

func RequestIDInterceptor() grpc.UnaryServerInterceptor

RequestIDInterceptor 是一个 gRPC 拦截器,用于设置请求 ID.

func ValidatorInterceptor

func ValidatorInterceptor(validator RequestValidator) grpc.UnaryServerInterceptor

ValidatorInterceptor 是一个 gRPC 拦截器,用于对请求进行验证.

Types

type Authorizer

type Authorizer interface {
	Authorize(subject, object, action string) (bool, error)
}

Authorizer 用于定义授权接口的实现.

type RequestValidator

type RequestValidator interface {
	Validate(ctx context.Context, rq any) error
}

RequestValidator 定义了用于自定义验证的接口.

type UserRetriever

type UserRetriever interface {
	// GetUser 根据用户 ID 获取用户信息
	GetUser(ctx context.Context, userID string) (*model.UserM, error)
}

UserRetriever 用于根据用户名获取用户信息的接口.

Jump to

Keyboard shortcuts

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