Documentation ¶
Index ¶
- Constants
- Variables
- func RegisterRpcServer(s grpc.ServiceRegistrar, srv RpcServer)
- type DescribeTokenRequest
- func (*DescribeTokenRequest) Descriptor() ([]byte, []int)deprecated
- func (x *DescribeTokenRequest) GetAccessToken() string
- func (*DescribeTokenRequest) ProtoMessage()
- func (x *DescribeTokenRequest) ProtoReflect() protoreflect.Message
- func (x *DescribeTokenRequest) Reset()
- func (x *DescribeTokenRequest) String() string
- type IssueTokenRequest
- func (*IssueTokenRequest) Descriptor() ([]byte, []int)deprecated
- 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
- type RevolkTokenRequest
- func (*RevolkTokenRequest) Descriptor() ([]byte, []int)deprecated
- func (x *RevolkTokenRequest) GetAccessToken() string
- func (x *RevolkTokenRequest) GetRefreshToken() string
- func (*RevolkTokenRequest) ProtoMessage()
- func (x *RevolkTokenRequest) ProtoReflect() protoreflect.Message
- func (x *RevolkTokenRequest) Reset()
- func (x *RevolkTokenRequest) String() string
- type RpcClient
- type RpcServer
- type Service
- type Token
- func (t *Token) AcccessTokenExpiredTime() time.Time
- func (*Token) Descriptor() ([]byte, []int)deprecated
- func (x *Token) GetAccessToken() string
- func (x *Token) GetAccessTokenExpiredSecond() int64
- func (x *Token) GetIssueAt() int64
- func (x *Token) GetRefreshToken() string
- func (x *Token) GetRefreshTokenExpiredSecond() int64
- func (x *Token) GetRoles() *role.RoleSet
- func (x *Token) GetUsername() string
- func (t *Token) HasPerm(servce, secret, action string) error
- func (t *Token) IsAcccessTokenExpired() bool
- func (t *Token) IsRefreshTokenExpired() bool
- func (t *Token) IssueTime() time.Time
- func (*Token) ProtoMessage()
- func (x *Token) ProtoReflect() protoreflect.Message
- func (t *Token) RefreshTokenExpiredTime() time.Time
- 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 ( HeaderAuthKey = "Authorization" CookieAuthKey = "mcenter_mini_token" )
客户端常量
const ( Rpc_IssueToken_FullMethodName = "/go11.devcloud_mini.token.Rpc/IssueToken" Rpc_ValidateToken_FullMethodName = "/go11.devcloud_mini.token.Rpc/ValidateToken" Rpc_DesribeToken_FullMethodName = "/go11.devcloud_mini.token.Rpc/DesribeToken" )
const (
AppName = "token"
)
const (
CONTEXT_ATTRIBUTE_KEY = "token"
)
服务端常量
Variables ¶
var File_mcenter_apps_token_pb_model_proto protoreflect.FileDescriptor
var File_mcenter_apps_token_pb_rpc_proto protoreflect.FileDescriptor
var Rpc_ServiceDesc = grpc.ServiceDesc{ ServiceName: "go11.devcloud_mini.token.Rpc", HandlerType: (*RpcServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "IssueToken", Handler: _Rpc_IssueToken_Handler, }, { MethodName: "ValidateToken", Handler: _Rpc_ValidateToken_Handler, }, { MethodName: "DesribeToken", Handler: _Rpc_DesribeToken_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "mcenter/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 DescribeTokenRequest ¶
type DescribeTokenRequest struct { // 需要被撤销的Token AccessToken string `protobuf:"bytes,1,opt,name=access_token,json=accessToken,proto3" json:"access_token,omitempty"` // contains filtered or unexported fields }
func NewDescribeTokenRequest ¶
func NewDescribeTokenRequest(ak string) *DescribeTokenRequest
func (*DescribeTokenRequest) Descriptor
deprecated
func (*DescribeTokenRequest) Descriptor() ([]byte, []int)
Deprecated: Use DescribeTokenRequest.ProtoReflect.Descriptor instead.
func (*DescribeTokenRequest) GetAccessToken ¶
func (x *DescribeTokenRequest) GetAccessToken() string
func (*DescribeTokenRequest) ProtoMessage ¶
func (*DescribeTokenRequest) ProtoMessage()
func (*DescribeTokenRequest) ProtoReflect ¶
func (x *DescribeTokenRequest) ProtoReflect() protoreflect.Message
func (*DescribeTokenRequest) Reset ¶
func (x *DescribeTokenRequest) Reset()
func (*DescribeTokenRequest) String ¶
func (x *DescribeTokenRequest) String() string
type IssueTokenRequest ¶
type IssueTokenRequest struct { // 用户名称 Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"` // 密码 Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"` // 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) 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
type RevolkTokenRequest ¶
type RevolkTokenRequest struct { // 需要被撤销的Token AccessToken string `protobuf:"bytes,1,opt,name=access_token,json=accessToken,proto3" json:"access_token,omitempty"` // 使用Refresh Token做撤销验证 RefreshToken string `protobuf:"bytes,2,opt,name=refresh_token,json=refreshToken,proto3" json:"refresh_token,omitempty"` // contains filtered or unexported fields }
func (*RevolkTokenRequest) Descriptor
deprecated
func (*RevolkTokenRequest) Descriptor() ([]byte, []int)
Deprecated: Use RevolkTokenRequest.ProtoReflect.Descriptor instead.
func (*RevolkTokenRequest) GetAccessToken ¶
func (x *RevolkTokenRequest) GetAccessToken() string
func (*RevolkTokenRequest) GetRefreshToken ¶
func (x *RevolkTokenRequest) GetRefreshToken() string
func (*RevolkTokenRequest) ProtoMessage ¶
func (*RevolkTokenRequest) ProtoMessage()
func (*RevolkTokenRequest) ProtoReflect ¶
func (x *RevolkTokenRequest) ProtoReflect() protoreflect.Message
func (*RevolkTokenRequest) Reset ¶
func (x *RevolkTokenRequest) Reset()
func (*RevolkTokenRequest) String ¶
func (x *RevolkTokenRequest) String() string
type RpcClient ¶
type RpcClient interface { // 令牌颁发 IssueToken(ctx context.Context, in *IssueTokenRequest, opts ...grpc.CallOption) (*Token, error) // 校验令牌, 给其他服务确认用户身份使用 ValidateToken(ctx context.Context, in *ValidateTokenRequest, opts ...grpc.CallOption) (*Token, error) // 获取Token, 内部Debug使用 DesribeToken(ctx context.Context, in *DescribeTokenRequest, 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 { // 令牌颁发 IssueToken(context.Context, *IssueTokenRequest) (*Token, error) // 校验令牌, 给其他服务确认用户身份使用 ValidateToken(context.Context, *ValidateTokenRequest) (*Token, error) // 获取Token, 内部Debug使用 DesribeToken(context.Context, *DescribeTokenRequest) (*Token, error) // contains filtered or unexported methods }
RpcServer is the server API for Rpc service. All implementations must embed UnimplementedRpcServer for forward compatibility
type Token ¶
type Token struct { // 访问令牌 // @gotags: json:"access_token" bson:"access_token" AccessToken string `protobuf:"bytes,1,opt,name=access_token,json=accessToken,proto3" json:"access_token" bson:"access_token"` // 刷新Token // @gotags: json:"refresh_token" bson:"refresh_token" RefreshToken string `protobuf:"bytes,2,opt,name=refresh_token,json=refreshToken,proto3" json:"refresh_token" bson:"refresh_token"` // 令牌颁发时间 // @gotags: json:"issue_at" bson:"issue_at" IssueAt int64 `protobuf:"varint,3,opt,name=issue_at,json=issueAt,proto3" json:"issue_at" bson:"issue_at"` // 多少秒后过期 // @gotags: json:"access_token_expired_second" bson:"access_token_expired_second" AccessTokenExpiredSecond int64 `` /* 163-byte string literal not displayed */ // 多少秒后过期 // @gotags: json:"refresh_token_expired_second" bson:"refresh_token_expired_second" RefreshTokenExpiredSecond int64 `` /* 167-byte string literal not displayed */ // 颁发的用户 // @gotags: json:"username" bson:"username" Username string `protobuf:"bytes,5,opt,name=username,proto3" json:"username" bson:"username"` // 用户的角色 // @gotags: json:"roles" bson:"roles" Roles *role.RoleSet `protobuf:"bytes,7,opt,name=roles,proto3" json:"roles" bson:"roles"` // contains filtered or unexported fields }
func (*Token) AcccessTokenExpiredTime ¶
func (*Token) Descriptor
deprecated
func (*Token) GetAccessToken ¶
func (*Token) GetAccessTokenExpiredSecond ¶
func (*Token) GetIssueAt ¶
func (*Token) GetRefreshToken ¶
func (*Token) GetRefreshTokenExpiredSecond ¶
func (*Token) GetUsername ¶
func (*Token) ProtoMessage ¶
func (*Token) ProtoMessage()
func (*Token) ProtoReflect ¶
func (x *Token) ProtoReflect() protoreflect.Message
func (*Token) RefreshTokenExpiredTime ¶
type UnimplementedRpcServer ¶
type UnimplementedRpcServer struct { }
UnimplementedRpcServer must be embedded to have forward compatible implementations.
func (UnimplementedRpcServer) DesribeToken ¶
func (UnimplementedRpcServer) DesribeToken(context.Context, *DescribeTokenRequest) (*Token, error)
func (UnimplementedRpcServer) IssueToken ¶
func (UnimplementedRpcServer) IssueToken(context.Context, *IssueTokenRequest) (*Token, error)
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 { // 需要被撤销的Token AccessToken string `protobuf:"bytes,1,opt,name=access_token,json=accessToken,proto3" json:"access_token,omitempty"` // contains filtered or unexported fields }
func NewValidateTokenRequest ¶
func NewValidateTokenRequest(tk 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