Documentation ¶
Index ¶
- Constants
- Variables
- func RegisterRPCServer(s grpc.ServiceRegistrar, srv RPCServer)
- type BLOCK_TYPE
- type GRANT_TYPE
- type IssueTokenRequest
- func (*IssueTokenRequest) Descriptor() ([]byte, []int)deprecated
- func (x *IssueTokenRequest) GetGrantType() GRANT_TYPE
- func (x *IssueTokenRequest) GetPassword() string
- func (x *IssueTokenRequest) GetUsername() string
- func (*IssueTokenRequest) ProtoMessage()
- func (x *IssueTokenRequest) ProtoReflect() protoreflect.Message
- func (x *IssueTokenRequest) Reset()
- func (x *IssueTokenRequest) String() string
- func (req *IssueTokenRequest) Validate() error
- type RPCClient
- type RPCServer
- type Service
- type Status
- func (*Status) Descriptor() ([]byte, []int)deprecated
- func (x *Status) GetBlockAt() int64
- func (x *Status) GetBlockReason() string
- func (x *Status) GetBlockType() BLOCK_TYPE
- func (x *Status) GetIsBlock() bool
- func (*Status) ProtoMessage()
- func (x *Status) ProtoReflect() protoreflect.Message
- func (x *Status) Reset()
- func (x *Status) String() string
- type TOKEN_TYPE
- type Token
- func (t *Token) CheckAliable() error
- func (*Token) Descriptor() ([]byte, []int)deprecated
- func (t *Token) ExpiredTime() time.Time
- func (x *Token) GetAccessExpiredAt() int64
- func (x *Token) GetAccessToken() string
- func (x *Token) GetGrantType() GRANT_TYPE
- func (x *Token) GetIssueAt() int64
- func (x *Token) GetMeta() map[string]string
- func (x *Token) GetNamespace() string
- func (x *Token) GetRefreshExpiredAt() int64
- func (x *Token) GetRefreshToken() string
- func (x *Token) GetStatus() *Status
- func (x *Token) GetType() TOKEN_TYPE
- func (x *Token) GetUserId() string
- func (x *Token) GetUsername() string
- func (*Token) ProtoMessage()
- func (x *Token) ProtoReflect() protoreflect.Message
- func (x *Token) Reset()
- func (x *Token) String() string
- type UnimplementedRPCServer
- type UnsafeRPCServer
- type ValidateTokenRequest
- func (*ValidateTokenRequest) Descriptor() ([]byte, []int)deprecated
- func (x *ValidateTokenRequest) GetAccessToken() string
- func (*ValidateTokenRequest) ProtoMessage()
- func (x *ValidateTokenRequest) ProtoReflect() protoreflect.Message
- func (x *ValidateTokenRequest) Reset()
- func (x *ValidateTokenRequest) String() string
Constants ¶
const ( // 标准认证头 TOKEN_HEADER_KEY = "Authorization" // 上下文中Token key 的名称 ATTRIBUTE_TOKEN_KEY = "token.mcenter" )
const (
AppName = "tokens"
)
Variables ¶
var ( GRANT_TYPE_name = map[int32]string{ 0: "PASSWORD", 1: "LDAP", 8: "FEISHU", 9: "DINGDING", } GRANT_TYPE_value = map[string]int32{ "PASSWORD": 0, "LDAP": 1, "FEISHU": 8, "DINGDING": 9, } )
Enum value maps for GRANT_TYPE.
var ( TOKEN_TYPE_name = map[int32]string{ 0: "BEARER", 1: "MAC", 2: "JWT", } TOKEN_TYPE_value = map[string]int32{ "BEARER": 0, "MAC": 1, "JWT": 2, } )
Enum value maps for TOKEN_TYPE.
var ( BLOCK_TYPE_name = map[int32]string{ 0: "REFRESH_TOKEN_EXPIRED", 1: "OTHER_PLACE_LOGGED_IN", 2: "OTHER_IP_LOGGED_IN", } BLOCK_TYPE_value = map[string]int32{ "REFRESH_TOKEN_EXPIRED": 0, "OTHER_PLACE_LOGGED_IN": 1, "OTHER_IP_LOGGED_IN": 2, } )
Enum value maps for BLOCK_TYPE.
var File_apps_token_pb_rpc_proto protoreflect.FileDescriptor
var File_apps_token_pb_token_proto protoreflect.FileDescriptor
var RPC_ServiceDesc = grpc.ServiceDesc{ ServiceName: "go9.devcloud.token.RPC", HandlerType: (*RPCServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "ValidateToken", Handler: _RPC_ValidateToken_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "apps/token/pb/rpc.proto", }
RPC_ServiceDesc is the grpc.ServiceDesc for RPC service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)
Functions ¶
func RegisterRPCServer ¶
func RegisterRPCServer(s grpc.ServiceRegistrar, srv RPCServer)
Types ¶
type BLOCK_TYPE ¶
type BLOCK_TYPE int32
冻结类型
const ( // 刷新Token过期, 回话中断 BLOCK_TYPE_REFRESH_TOKEN_EXPIRED BLOCK_TYPE = 0 // 异地登陆 BLOCK_TYPE_OTHER_PLACE_LOGGED_IN BLOCK_TYPE = 1 // 异常Ip登陆 BLOCK_TYPE_OTHER_IP_LOGGED_IN BLOCK_TYPE = 2 )
func (BLOCK_TYPE) Descriptor ¶
func (BLOCK_TYPE) Descriptor() protoreflect.EnumDescriptor
func (BLOCK_TYPE) Enum ¶
func (x BLOCK_TYPE) Enum() *BLOCK_TYPE
func (BLOCK_TYPE) EnumDescriptor
deprecated
func (BLOCK_TYPE) EnumDescriptor() ([]byte, []int)
Deprecated: Use BLOCK_TYPE.Descriptor instead.
func (BLOCK_TYPE) Number ¶
func (x BLOCK_TYPE) Number() protoreflect.EnumNumber
func (BLOCK_TYPE) String ¶
func (x BLOCK_TYPE) String() string
func (BLOCK_TYPE) Type ¶
func (BLOCK_TYPE) Type() protoreflect.EnumType
type GRANT_TYPE ¶
type GRANT_TYPE int32
授权类型
const ( // 用户密码授权 GRANT_TYPE_PASSWORD GRANT_TYPE = 0 // LDAP授权 GRANT_TYPE_LDAP GRANT_TYPE = 1 // 飞书授权 GRANT_TYPE_FEISHU GRANT_TYPE = 8 // 飞书授权 GRANT_TYPE_DINGDING GRANT_TYPE = 9 )
func (GRANT_TYPE) Descriptor ¶
func (GRANT_TYPE) Descriptor() protoreflect.EnumDescriptor
func (GRANT_TYPE) Enum ¶
func (x GRANT_TYPE) Enum() *GRANT_TYPE
func (GRANT_TYPE) EnumDescriptor
deprecated
func (GRANT_TYPE) EnumDescriptor() ([]byte, []int)
Deprecated: Use GRANT_TYPE.Descriptor instead.
func (GRANT_TYPE) Number ¶
func (x GRANT_TYPE) Number() protoreflect.EnumNumber
func (GRANT_TYPE) String ¶
func (x GRANT_TYPE) String() string
func (GRANT_TYPE) Type ¶
func (GRANT_TYPE) Type() protoreflect.EnumType
type IssueTokenRequest ¶
type IssueTokenRequest struct { // 授权类型 // @gotags: bson:"grant_type" json:"grant_type" GrantType GRANT_TYPE `` /* 132-byte string literal not displayed */ // 用户名 // @gotags: bson:"username" json:"username" Username string `protobuf:"bytes,2,opt,name=username,proto3" json:"username" bson:"username"` // 用户名 // @gotags: bson:"password" json:"password" Password string `protobuf:"bytes,3,opt,name=password,proto3" json:"password" bson:"password"` // contains filtered or unexported fields }
func NewIssueTokenRequest ¶
func NewIssueTokenRequest() *IssueTokenRequest
func (*IssueTokenRequest) Descriptor
deprecated
func (*IssueTokenRequest) Descriptor() ([]byte, []int)
Deprecated: Use IssueTokenRequest.ProtoReflect.Descriptor instead.
func (*IssueTokenRequest) GetGrantType ¶
func (x *IssueTokenRequest) GetGrantType() GRANT_TYPE
func (*IssueTokenRequest) GetPassword ¶
func (x *IssueTokenRequest) GetPassword() string
func (*IssueTokenRequest) GetUsername ¶
func (x *IssueTokenRequest) GetUsername() string
func (*IssueTokenRequest) ProtoMessage ¶
func (*IssueTokenRequest) ProtoMessage()
func (*IssueTokenRequest) ProtoReflect ¶
func (x *IssueTokenRequest) ProtoReflect() protoreflect.Message
func (*IssueTokenRequest) Reset ¶
func (x *IssueTokenRequest) Reset()
func (*IssueTokenRequest) String ¶
func (x *IssueTokenRequest) String() string
func (*IssueTokenRequest) Validate ¶
func (req *IssueTokenRequest) Validate() error
type RPCClient ¶
type RPCClient interface { // 令牌的校验: Grpc, 获取Token, 判断Token是否冻结或者过期 ValidateToken(ctx context.Context, in *ValidateTokenRequest, opts ...grpc.CallOption) (*Token, error) }
RPCClient is the client API for RPC service.
For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
func NewRPCClient ¶
func NewRPCClient(cc grpc.ClientConnInterface) RPCClient
type RPCServer ¶
type RPCServer interface { // 令牌的校验: Grpc, 获取Token, 判断Token是否冻结或者过期 ValidateToken(context.Context, *ValidateTokenRequest) (*Token, error) // contains filtered or unexported methods }
RPCServer is the server API for RPC service. All implementations must embed UnimplementedRPCServer for forward compatibility
type Status ¶
type Status struct { // 是否冻结 // @gotags: bson:"is_block" json:"is_block" IsBlock bool `protobuf:"varint,1,opt,name=is_block,json=isBlock,proto3" json:"is_block" bson:"is_block"` // 冻结类型 // @gotags: bson:"block_type" json:"block_type" BlockType BLOCK_TYPE `` /* 132-byte string literal not displayed */ // 冻结时间 // @gotags: bson:"block_at" json:"block_at" BlockAt int64 `protobuf:"varint,3,opt,name=block_at,json=blockAt,proto3" json:"block_at" bson:"block_at"` // 冻结原因 // @gotags: bson:"block_reason" json:"block_reason" BlockReason string `protobuf:"bytes,4,opt,name=block_reason,json=blockReason,proto3" json:"block_reason" bson:"block_reason"` // contains filtered or unexported fields }
func (*Status) Descriptor
deprecated
func (*Status) GetBlockAt ¶
func (*Status) GetBlockReason ¶
func (*Status) GetBlockType ¶
func (x *Status) GetBlockType() BLOCK_TYPE
func (*Status) GetIsBlock ¶
func (*Status) ProtoMessage ¶
func (*Status) ProtoMessage()
func (*Status) ProtoReflect ¶
func (x *Status) ProtoReflect() protoreflect.Message
type TOKEN_TYPE ¶
type TOKEN_TYPE int32
令牌类型
const ( // Bearer Token: xxxx TOKEN_TYPE_BEARER TOKEN_TYPE = 0 // 基于Mac的Token TOKEN_TYPE_MAC TOKEN_TYPE = 1 // Json Web Token TOKEN_TYPE_JWT TOKEN_TYPE = 2 )
func (TOKEN_TYPE) Descriptor ¶
func (TOKEN_TYPE) Descriptor() protoreflect.EnumDescriptor
func (TOKEN_TYPE) Enum ¶
func (x TOKEN_TYPE) Enum() *TOKEN_TYPE
func (TOKEN_TYPE) EnumDescriptor
deprecated
func (TOKEN_TYPE) EnumDescriptor() ([]byte, []int)
Deprecated: Use TOKEN_TYPE.Descriptor instead.
func (TOKEN_TYPE) Number ¶
func (x TOKEN_TYPE) Number() protoreflect.EnumNumber
func (TOKEN_TYPE) String ¶
func (x TOKEN_TYPE) String() string
func (TOKEN_TYPE) Type ¶
func (TOKEN_TYPE) Type() protoreflect.EnumType
type Token ¶
type Token struct { // 访问令牌 // @gotags: bson:"_id" json:"access_token" AccessToken string `protobuf:"bytes,1,opt,name=access_token,json=accessToken,proto3" json:"access_token" bson:"_id"` // 刷新令牌 // @gotags: bson:"refresh_token" json:"refresh_token" RefreshToken string `protobuf:"bytes,2,opt,name=refresh_token,json=refreshToken,proto3" json:"refresh_token" bson:"refresh_token"` // 颁发时间 // @gotags: bson:"issue_at" json:"issue_at" IssueAt int64 `protobuf:"varint,3,opt,name=issue_at,json=issueAt,proto3" json:"issue_at" bson:"issue_at"` // 访问令牌过期时间 // @gotags: bson:"access_expired_at" json:"access_expired_at" AccessExpiredAt int64 `protobuf:"varint,4,opt,name=access_expired_at,json=accessExpiredAt,proto3" json:"access_expired_at" bson:"access_expired_at"` // 刷新令牌过期时间 // @gotags: bson:"refresh_expired_at" json:"refresh_expired_at" RefreshExpiredAt int64 `` /* 128-byte string literal not displayed */ // 授权类型 // @gotags: bson:"grant_type" json:"grant_type" GrantType GRANT_TYPE `` /* 133-byte string literal not displayed */ // 用户所在的空间, 用户访问访问 // @gotags: bson:"namespace" json:"namespace" Namespace string `protobuf:"bytes,7,opt,name=namespace,proto3" json:"namespace" bson:"namespace"` // 用户名 // @gotags: bson:"username" json:"username" Username string `protobuf:"bytes,6,opt,name=username,proto3" json:"username" bson:"username"` // 用户Id // @gotags: bson:"user_id" json:"user_id" UserId string `protobuf:"bytes,8,opt,name=user_id,json=userId,proto3" json:"user_id" bson:"user_id"` // 令牌类型 // @gotags: bson:"type" json:"type" Type TOKEN_TYPE `protobuf:"varint,12,opt,name=type,proto3,enum=go9.devcloud.token.TOKEN_TYPE" json:"type" bson:"type"` // 令牌状态 // @gotags: bson:"status" json:"status,omitempty" Status *Status `protobuf:"bytes,13,opt,name=status,proto3" json:"status,omitempty" bson:"status"` // 其他信息 // @gotags: bson:"meta" json:"meta,omitempty" Meta map[string]string `` /* 162-byte string literal not displayed */ // contains filtered or unexported fields }
func (*Token) Descriptor
deprecated
func (*Token) ExpiredTime ¶
func (*Token) GetAccessExpiredAt ¶
func (*Token) GetAccessToken ¶
func (*Token) GetGrantType ¶
func (x *Token) GetGrantType() GRANT_TYPE
func (*Token) GetIssueAt ¶
func (*Token) GetNamespace ¶
func (*Token) GetRefreshExpiredAt ¶
func (*Token) GetRefreshToken ¶
func (*Token) GetType ¶
func (x *Token) GetType() TOKEN_TYPE
func (*Token) GetUsername ¶
func (*Token) ProtoMessage ¶
func (*Token) ProtoMessage()
func (*Token) ProtoReflect ¶
func (x *Token) ProtoReflect() protoreflect.Message
type UnimplementedRPCServer ¶
type UnimplementedRPCServer struct { }
UnimplementedRPCServer must be embedded to have forward compatible implementations.
func (UnimplementedRPCServer) ValidateToken ¶
func (UnimplementedRPCServer) ValidateToken(context.Context, *ValidateTokenRequest) (*Token, error)
type UnsafeRPCServer ¶
type UnsafeRPCServer interface {
// contains filtered or unexported methods
}
UnsafeRPCServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to RPCServer will result in compilation errors.
type ValidateTokenRequest ¶
type ValidateTokenRequest struct { // 用户名 // @gotags: bson:"access_token" json:"access_token" AccessToken string `protobuf:"bytes,2,opt,name=access_token,json=accessToken,proto3" json:"access_token" bson:"access_token"` // contains filtered or unexported fields }
func NewValidateTokenRequest ¶
func NewValidateTokenRequest(ak string) *ValidateTokenRequest
func (*ValidateTokenRequest) Descriptor
deprecated
func (*ValidateTokenRequest) Descriptor() ([]byte, []int)
Deprecated: Use ValidateTokenRequest.ProtoReflect.Descriptor instead.
func (*ValidateTokenRequest) GetAccessToken ¶
func (x *ValidateTokenRequest) GetAccessToken() string
func (*ValidateTokenRequest) ProtoMessage ¶
func (*ValidateTokenRequest) ProtoMessage()
func (*ValidateTokenRequest) ProtoReflect ¶
func (x *ValidateTokenRequest) ProtoReflect() protoreflect.Message
func (*ValidateTokenRequest) Reset ¶
func (x *ValidateTokenRequest) Reset()
func (*ValidateTokenRequest) String ¶
func (x *ValidateTokenRequest) String() string