Documentation ¶
Overview ¶
@Author: Ciusyan 2023/2/6
Index ¶
- Constants
- Variables
- func RegisterServiceServer(s grpc.ServiceRegistrar, srv ServiceServer)
- type IssueTokenRequest
- func (*IssueTokenRequest) Descriptor() ([]byte, []int)deprecated
- func (x *IssueTokenRequest) GetUserId() int64
- func (x *IssueTokenRequest) GetUsername() string
- func (*IssueTokenRequest) ProtoMessage()
- func (x *IssueTokenRequest) ProtoReflect() protoreflect.Message
- func (x *IssueTokenRequest) Reset()
- func (x *IssueTokenRequest) String() string
- type ServiceClient
- type ServiceServer
- type Token
- func (*Token) Descriptor() ([]byte, []int)deprecated
- func (t *Token) Extend(expiredDuration time.Duration) *Token
- func (x *Token) GetAccessToken() string
- func (x *Token) GetAccessTokenExpiredAt() int64
- func (x *Token) GetIssueAt() int64
- func (x *Token) GetIssueBy() string
- func (x *Token) GetMeta() map[string]string
- func (x *Token) GetRefreshToken() string
- func (x *Token) GetRefreshTokenExpiredAt() int64
- func (x *Token) GetUpdateAt() int64
- func (x *Token) GetUpdateBy() string
- func (t *Token) GetUserId() int64
- func (s *Token) IsExpired(expiredAt int64) bool
- func (*Token) ProtoMessage()
- func (x *Token) ProtoReflect() protoreflect.Message
- func (x *Token) Reset()
- func (x *Token) String() string
- type UIDResponse
- type UnimplementedServiceServer
- func (UnimplementedServiceServer) GetUIDFromTk(context.Context, *ValidateTokenRequest) (*UIDResponse, error)
- func (UnimplementedServiceServer) IssueToken(context.Context, *IssueTokenRequest) (*Token, error)
- func (UnimplementedServiceServer) ValidateToken(context.Context, *ValidateTokenRequest) (*Token, error)
- type UnsafeServiceServer
- 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 (
AppName = "token"
)
Variables ¶
var File_apps_token_pb_token_proto protoreflect.FileDescriptor
var Service_ServiceDesc = grpc.ServiceDesc{ ServiceName: "dousheng.token.Service", HandlerType: (*ServiceServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "IssueToken", Handler: _Service_IssueToken_Handler, }, { MethodName: "ValidateToken", Handler: _Service_ValidateToken_Handler, }, { MethodName: "GetUIDFromTk", Handler: _Service_GetUIDFromTk_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "apps/token/pb/token.proto", }
Service_ServiceDesc is the grpc.ServiceDesc for Service service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)
Functions ¶
func RegisterServiceServer ¶
func RegisterServiceServer(s grpc.ServiceRegistrar, srv ServiceServer)
Types ¶
type IssueTokenRequest ¶
type IssueTokenRequest struct { // 颁发人名称 // @gotags: json:"username" bson:"username" Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username" bson:"username"` // 颁发人ID // @gotags: json:"user_id" bson:"user_id" UserId int64 `protobuf:"varint,2,opt,name=user_id,json=userId,proto3" json:"user_id" bson:"user_id"` // contains filtered or unexported fields }
func (*IssueTokenRequest) Descriptor
deprecated
func (*IssueTokenRequest) Descriptor() ([]byte, []int)
Deprecated: Use IssueTokenRequest.ProtoReflect.Descriptor instead.
func (*IssueTokenRequest) GetUserId ¶
func (x *IssueTokenRequest) GetUserId() int64
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 ServiceClient ¶
type ServiceClient interface { // 颁发 Token IssueToken(ctx context.Context, in *IssueTokenRequest, opts ...grpc.CallOption) (*Token, error) // 验证Token (内部服务使用) ValidateToken(ctx context.Context, in *ValidateTokenRequest, opts ...grpc.CallOption) (*Token, error) // 根据Token解析出 user_id GetUIDFromTk(ctx context.Context, in *ValidateTokenRequest, opts ...grpc.CallOption) (*UIDResponse, error) }
ServiceClient is the client API for Service 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 NewServiceClient ¶
func NewServiceClient(cc grpc.ClientConnInterface) ServiceClient
type ServiceServer ¶
type ServiceServer interface { // 颁发 Token IssueToken(context.Context, *IssueTokenRequest) (*Token, error) // 验证Token (内部服务使用) ValidateToken(context.Context, *ValidateTokenRequest) (*Token, error) // 根据Token解析出 user_id GetUIDFromTk(context.Context, *ValidateTokenRequest) (*UIDResponse, error) // contains filtered or unexported methods }
ServiceServer is the server API for Service service. All implementations must embed UnimplementedServiceServer for forward compatibility
type Token ¶
type Token struct { // 唯一ID // @gotags: json:"access_token" bson:"_id" AccessToken string `protobuf:"bytes,1,opt,name=access_token,json=accessToken,proto3" json:"access_token" bson:"_id"` // 颁发时间 // @gotags: json:"issue_at" bson:"issue_at" IssueAt int64 `protobuf:"varint,2,opt,name=issue_at,json=issueAt,proto3" json:"issue_at" bson:"issue_at"` // 颁发人 // @gotags: json:"issue_by" bson:"issue_by" IssueBy string `protobuf:"bytes,3,opt,name=issue_by,json=issueBy,proto3" json:"issue_by" bson:"issue_by"` // 更新时间 // @gotags: json:"update_at" bson:"update_at" UpdateAt int64 `protobuf:"varint,4,opt,name=update_at,json=updateAt,proto3" json:"update_at" bson:"update_at"` // 更新人 // @gotags: json:"update_by" bson:"update_by" UpdateBy string `protobuf:"bytes,5,opt,name=update_by,json=updateBy,proto3" json:"update_by" bson:"update_by"` // Access Token过期时间(绝对时间), 10分钟, now() + 10分钟 // @gotags: json:"access_token_expired_at" bson:"access_token_expired_at" AccessTokenExpiredAt int64 `` /* 147-byte string literal not displayed */ // token过期了, 允许刷新 // @gotags: json:"refresh_token" bson:"refresh_token" RefreshToken string `protobuf:"bytes,7,opt,name=refresh_token,json=refreshToken,proto3" json:"refresh_token" bson:"refresh_token"` // Access Token过期时间(绝对时间), 10分钟, now() + 10分钟 // @gotags: json:"refresh_token_expired_at" bson:"refresh_token_expired_at" RefreshTokenExpiredAt int64 `` /* 151-byte string literal not displayed */ // 用于传递额外信息 // @gotags: json:"meta" bson:"meta" Meta map[string]string `` /* 152-byte string literal not displayed */ // contains filtered or unexported fields }
Token
func NewDefaultToken ¶
func NewDefaultToken() *Token
func (*Token) Descriptor
deprecated
func (*Token) GetAccessToken ¶
func (*Token) GetAccessTokenExpiredAt ¶
func (*Token) GetIssueAt ¶
func (*Token) GetIssueBy ¶
func (*Token) GetRefreshToken ¶
func (*Token) GetRefreshTokenExpiredAt ¶
func (*Token) GetUpdateAt ¶
func (*Token) GetUpdateBy ¶
func (*Token) ProtoMessage ¶
func (*Token) ProtoMessage()
func (*Token) ProtoReflect ¶
func (x *Token) ProtoReflect() protoreflect.Message
type UIDResponse ¶
type UIDResponse struct { // access token // @gotags: json:"user_id" UserId int64 `protobuf:"varint,1,opt,name=user_id,json=userId,proto3" json:"user_id"` // contains filtered or unexported fields }
func NewUIDResponse ¶
func NewUIDResponse() *UIDResponse
func (*UIDResponse) Descriptor
deprecated
func (*UIDResponse) Descriptor() ([]byte, []int)
Deprecated: Use UIDResponse.ProtoReflect.Descriptor instead.
func (*UIDResponse) GetUserId ¶
func (x *UIDResponse) GetUserId() int64
func (*UIDResponse) ProtoMessage ¶
func (*UIDResponse) ProtoMessage()
func (*UIDResponse) ProtoReflect ¶
func (x *UIDResponse) ProtoReflect() protoreflect.Message
func (*UIDResponse) Reset ¶
func (x *UIDResponse) Reset()
func (*UIDResponse) String ¶
func (x *UIDResponse) String() string
type UnimplementedServiceServer ¶
type UnimplementedServiceServer struct { }
UnimplementedServiceServer must be embedded to have forward compatible implementations.
func (UnimplementedServiceServer) GetUIDFromTk ¶
func (UnimplementedServiceServer) GetUIDFromTk(context.Context, *ValidateTokenRequest) (*UIDResponse, error)
func (UnimplementedServiceServer) IssueToken ¶
func (UnimplementedServiceServer) IssueToken(context.Context, *IssueTokenRequest) (*Token, error)
func (UnimplementedServiceServer) ValidateToken ¶
func (UnimplementedServiceServer) ValidateToken(context.Context, *ValidateTokenRequest) (*Token, error)
type UnsafeServiceServer ¶
type UnsafeServiceServer interface {
// contains filtered or unexported methods
}
UnsafeServiceServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to ServiceServer will result in compilation errors.
type ValidateTokenRequest ¶
type ValidateTokenRequest struct { // access token // @gotags: json:"access_token" AccessToken string `protobuf:"bytes,1,opt,name=access_token,json=accessToken,proto3" json:"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