Documentation ¶
Index ¶
- Variables
- func Cors() func(http.Handler) http.Handler
- func GetOperation(ctx context.Context) string
- func GetSourceType(ctx context.Context) vobj.SourceType
- func GetTeamID(ctx context.Context) uint32
- func GetTeamMemberID(ctx context.Context) uint32
- func GetUserID(ctx context.Context) uint32
- func GetUserRole(ctx context.Context) vobj.Role
- func I18N() middleware.Middleware
- func IsExpire(jwtClaims *JwtClaims) bool
- func JwtLoginMiddleware(check CheckTokenFun) middleware.Middleware
- func JwtServer() middleware.Middleware
- func Logging(logger log.Logger) middleware.Middleware
- func NewWhiteListMatcher(list []string) selector.MatchFunc
- func Rbac(check CheckRbacFun) middleware.Middleware
- func SetExpire(e time.Duration)
- func SetIssuer(iss string)
- func SetJwtConfig(cfg JWTConfig)
- func SetSignKey(key string)
- func SourceType() middleware.Middleware
- func Validate(opts ...protovalidate.ValidatorOption) middleware.Middleware
- func WithTeamIDContextKey(ctx context.Context, id uint32) context.Context
- func WithTeamMemberIDContextKey(ctx context.Context, id uint32) context.Context
- func WithUserIDContextKey(ctx context.Context, id uint32) context.Context
- func WithUserRoleContextKey(ctx context.Context, role vobj.Role) context.Context
- type CheckRbacFun
- type CheckTokenFun
- type JWTConfig
- type JwtBaseInfo
- func (l *JwtBaseInfo) GetMember() uint32
- func (l *JwtBaseInfo) GetTeam() uint32
- func (l *JwtBaseInfo) GetUser() uint32
- func (l *JwtBaseInfo) SetMember(memberID uint32) *JwtBaseInfo
- func (l *JwtBaseInfo) SetTeamInfo(teamID uint32) *JwtBaseInfo
- func (l *JwtBaseInfo) SetUserInfo(userID uint32) *JwtBaseInfo
- type JwtClaims
- type Selector
- type ValidateHandler
Constants ¶
This section is empty.
Variables ¶
var LocaleFS embed.FS
LocaleFS 加载国际化文件
Functions ¶
func GetOperation ¶
GetOperation is get operation from context
func GetSourceType ¶
func GetSourceType(ctx context.Context) vobj.SourceType
GetSourceType get source type
func GetTeamMemberID ¶ added in v1.1.0
GetTeamMemberID get team member id
func JwtLoginMiddleware ¶
func JwtLoginMiddleware(check CheckTokenFun) middleware.Middleware
JwtLoginMiddleware jwt login middleware
func Logging ¶
func Logging(logger log.Logger) middleware.Middleware
Logging is an server logging middleware.
func NewWhiteListMatcher ¶
NewWhiteListMatcher new white list matcher
func SourceType ¶
func SourceType() middleware.Middleware
SourceType 获取请求头中的Source-Type sourceType System Team
func Validate ¶
func Validate(opts ...protovalidate.ValidatorOption) middleware.Middleware
Validate 验证请求参数
func WithTeamIDContextKey ¶ added in v1.1.0
WithTeamIDContextKey with team id context key
func WithTeamMemberIDContextKey ¶ added in v1.1.0
WithTeamMemberIDContextKey with team member id context key
func WithUserIDContextKey ¶ added in v1.1.0
WithUserIDContextKey with user id context key
Types ¶
type CheckRbacFun ¶
type CheckRbacFun func(ctx context.Context, operation string) (*authorizationapi.CheckPermissionReply, error)
CheckRbacFun 权限校验函数
type CheckTokenFun ¶
type CheckTokenFun func(ctx context.Context) (*authorization.CheckTokenReply, error)
CheckTokenFun check token fun
type JWTConfig ¶ added in v1.1.38
type JWTConfig interface { // GetSignKey get sign key GetSignKey() string // GetExpire get expire GetExpire() *durationpb.Duration // GetIssuer get issuer GetIssuer() string }
JWTConfig jwt config
type JwtBaseInfo ¶
type JwtBaseInfo struct { UserID uint32 `json:"user"` TeamID uint32 `json:"team"` MemberID uint32 `json:"member"` }
JwtBaseInfo jwt base info
func (*JwtBaseInfo) SetMember ¶
func (l *JwtBaseInfo) SetMember(memberID uint32) *JwtBaseInfo
SetMember 设置成员信息
func (*JwtBaseInfo) SetTeamInfo ¶
func (l *JwtBaseInfo) SetTeamInfo(teamID uint32) *JwtBaseInfo
SetTeamInfo 设置团队信息
func (*JwtBaseInfo) SetUserInfo ¶
func (l *JwtBaseInfo) SetUserInfo(userID uint32) *JwtBaseInfo
SetUserInfo 设置用户信息
type JwtClaims ¶
type JwtClaims struct { *JwtBaseInfo *jwtv5.RegisteredClaims }
JwtClaims jwt claims
func ParseJwtClaims ¶
ParseJwtClaims parse jwt claims
type Selector ¶
type Selector struct {
// contains filtered or unexported fields
}
Selector is middleware selector
func (*Selector) Build ¶
func (b *Selector) Build() middle.Middleware
Build is Builder's Build, for example: Server().Path(m1,m2).Build()
type ValidateHandler ¶
ValidateHandler 验证请求参数处理器
func ValidateParams ¶
func ValidateParams(opts ...protovalidate.ValidatorOption) ValidateHandler
ValidateParams 验证请求参数