Documentation ¶
Index ¶
- Constants
- Variables
- func RegisterServiceServer(s grpc.ServiceRegistrar, srv ServiceServer)
- 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 GrantType
- func (GrantType) Descriptor() protoreflect.EnumDescriptor
- func (x GrantType) Enum() *GrantType
- func (GrantType) EnumDescriptor() ([]byte, []int)deprecated
- func (t GrantType) Equal(target GrantType) bool
- func (t GrantType) IsIn(targets ...GrantType) bool
- func (t GrantType) MarshalJSON() ([]byte, error)
- func (x GrantType) Number() protoreflect.EnumNumber
- func (x GrantType) String() string
- func (GrantType) Type() protoreflect.EnumType
- func (t *GrantType) UnmarshalJSON(b []byte) error
- type IssueTokenRequest
- func (*IssueTokenRequest) Descriptor() ([]byte, []int)deprecated
- func (x *IssueTokenRequest) GetGrantType() GrantType
- func (x *IssueTokenRequest) GetPassword() string
- func (x *IssueTokenRequest) GetUserDomain() 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 QueryTokenRequest
- func (*QueryTokenRequest) Descriptor() ([]byte, []int)deprecated
- func (x *QueryTokenRequest) GetKeywords() string
- func (x *QueryTokenRequest) GetPage() *page.PageRequest
- func (*QueryTokenRequest) ProtoMessage()
- func (x *QueryTokenRequest) ProtoReflect() protoreflect.Message
- func (x *QueryTokenRequest) Reset()
- func (x *QueryTokenRequest) 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 ServiceClient
- type ServiceServer
- type Token
- func (*Token) Descriptor() ([]byte, []int)deprecated
- func (t *Token) Extend(expiredDuration time.Duration)
- func (x *Token) GetAccessToken() string
- func (x *Token) GetAccessTokenExpiredAt() int64
- func (x *Token) GetData() *IssueTokenRequest
- func (x *Token) GetIssueAt() int64
- 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) IsRefreshTokenExpired() bool
- func (*Token) ProtoMessage()
- func (x *Token) ProtoReflect() protoreflect.Message
- func (x *Token) Reset()
- func (x *Token) String() string
- func (t *Token) Validate() error
- type TokenSet
- type UnimplementedServiceServer
- func (UnimplementedServiceServer) IssueToken(context.Context, *IssueTokenRequest) (*Token, error)
- func (UnimplementedServiceServer) QueryToken(context.Context, *QueryTokenRequest) (*TokenSet, error)
- func (UnimplementedServiceServer) RevolkToken(context.Context, *RevolkTokenRequest) (*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 ( Service_IssueToken_FullMethodName = "/keyauth.authtoken.Service/IssueToken" Service_RevolkToken_FullMethodName = "/keyauth.authtoken.Service/RevolkToken" Service_ValidateToken_FullMethodName = "/keyauth.authtoken.Service/ValidateToken" Service_QueryToken_FullMethodName = "/keyauth.authtoken.Service/QueryToken" )
const (
AppName = "token"
)
Variables ¶
var ( GrantType_name = map[int32]string{ 0: "PASSWORD", 1: "LADP", 2: "ACCESS_TOKEN", 3: "REFRESH_TOKEN", } GrantType_value = map[string]int32{ "PASSWORD": 0, "LADP": 1, "ACCESS_TOKEN": 2, "REFRESH_TOKEN": 3, } )
Enum value maps for GrantType.
var File_apps_token_pb_authtoken_proto protoreflect.FileDescriptor
var Service_ServiceDesc = grpc.ServiceDesc{ ServiceName: "keyauth.authtoken.Service", HandlerType: (*ServiceServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "IssueToken", Handler: _Service_IssueToken_Handler, }, { MethodName: "RevolkToken", Handler: _Service_RevolkToken_Handler, }, { MethodName: "ValidateToken", Handler: _Service_ValidateToken_Handler, }, { MethodName: "QueryToken", Handler: _Service_QueryToken_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "apps/token/pb/authtoken.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 DescribeTokenRequest ¶
type DescribeTokenRequest 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 NewDescribeTokenRequest ¶
func NewDescribeTokenRequest(at 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 GrantType ¶
type GrantType int32
授权的类型
const ( // 通过Password授权 GrantType_PASSWORD GrantType = 0 // LDAP认证 GrantType_LADP GrantType = 1 // 通过ACCESS TOKEN来获取一个 TK, 用户API用户访问(RESTful SDK) // 通过一个User Password的Token 来生成一个 ACCESS TOKEN // HTTP API 编程访问 GrantType_ACCESS_TOKEN GrantType = 2 // 通过REFRESH TOKEN获取令牌 GrantType_REFRESH_TOKEN GrantType = 3 )
func ParseGrantTypeFromString ¶
ParseGrantTypeFromString Parse GrantType from string
func (GrantType) Descriptor ¶
func (GrantType) Descriptor() protoreflect.EnumDescriptor
func (GrantType) EnumDescriptor
deprecated
func (GrantType) Number ¶
func (x GrantType) Number() protoreflect.EnumNumber
func (GrantType) Type ¶
func (GrantType) Type() protoreflect.EnumType
func (*GrantType) UnmarshalJSON ¶
UnmarshalJSON todo
type IssueTokenRequest ¶
type IssueTokenRequest struct { // 授权类型 // @gotags: json:"grant_type" bson:"grant_type" GrantType GrantType `` /* 130-byte string literal not displayed */ // 授权类型 // @gotags: json:"domain" bson:"domain" UserDomain string `protobuf:"bytes,2,opt,name=user_domain,json=userDomain,proto3" json:"domain" bson:"domain"` // 授权类型 // @gotags: json:"user_name" bson:"user_name" UserName string `protobuf:"bytes,3,opt,name=user_name,json=userName,proto3" json:"user_name" bson:"user_name"` // 授权类型 // @gotags: json:"password" bson:"-" Password string `protobuf:"bytes,4,opt,name=password,proto3" json:"password" bson:"-"` // 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() GrantType
func (*IssueTokenRequest) GetPassword ¶
func (x *IssueTokenRequest) GetPassword() string
func (*IssueTokenRequest) GetUserDomain ¶
func (x *IssueTokenRequest) GetUserDomain() 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 QueryTokenRequest ¶
type QueryTokenRequest struct { // 分页参数 // @gotags: json:"page" Page *page.PageRequest `protobuf:"bytes,1,opt,name=page,proto3" json:"page"` // 关键字参数 // @gotags: json:"keywords" Keywords string `protobuf:"bytes,2,opt,name=keywords,proto3" json:"keywords"` // contains filtered or unexported fields }
func (*QueryTokenRequest) Descriptor
deprecated
func (*QueryTokenRequest) Descriptor() ([]byte, []int)
Deprecated: Use QueryTokenRequest.ProtoReflect.Descriptor instead.
func (*QueryTokenRequest) GetKeywords ¶
func (x *QueryTokenRequest) GetKeywords() string
func (*QueryTokenRequest) GetPage ¶
func (x *QueryTokenRequest) GetPage() *page.PageRequest
func (*QueryTokenRequest) ProtoMessage ¶
func (*QueryTokenRequest) ProtoMessage()
func (*QueryTokenRequest) ProtoReflect ¶
func (x *QueryTokenRequest) ProtoReflect() protoreflect.Message
func (*QueryTokenRequest) Reset ¶
func (x *QueryTokenRequest) Reset()
func (*QueryTokenRequest) String ¶
func (x *QueryTokenRequest) String() string
type RevolkTokenRequest ¶
type RevolkTokenRequest struct { // access token // @gotags: json:"access_token" AccessToken string `protobuf:"bytes,1,opt,name=access_token,json=accessToken,proto3" json:"access_token"` // refresh token, 当做撤销凭证 // @gotags: json:"refresh_token" RefreshToken string `protobuf:"bytes,2,opt,name=refresh_token,json=refreshToken,proto3" json:"refresh_token"` // contains filtered or unexported fields }
func NewRevolkTokenRequest ¶
func NewRevolkTokenRequest() *RevolkTokenRequest
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 ServiceClient ¶
type ServiceClient interface { // 颁发Token(Login) IssueToken(ctx context.Context, in *IssueTokenRequest, opts ...grpc.CallOption) (*Token, error) // 撤销Token(Logout) RevolkToken(ctx context.Context, in *RevolkTokenRequest, opts ...grpc.CallOption) (*Token, error) // 校验Token的接口(内部服务使用) ValidateToken(ctx context.Context, in *ValidateTokenRequest, opts ...grpc.CallOption) (*Token, error) // 查询Token, 查询用于REST ful API访问颁发出去的Token QueryToken(ctx context.Context, in *QueryTokenRequest, opts ...grpc.CallOption) (*TokenSet, 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(Login) IssueToken(context.Context, *IssueTokenRequest) (*Token, error) // 撤销Token(Logout) RevolkToken(context.Context, *RevolkTokenRequest) (*Token, error) // 校验Token的接口(内部服务使用) ValidateToken(context.Context, *ValidateTokenRequest) (*Token, error) // 查询Token, 查询用于REST ful API访问颁发出去的Token QueryToken(context.Context, *QueryTokenRequest) (*TokenSet, 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:"update_at" bson:"update_at" UpdateAt int64 `protobuf:"varint,3,opt,name=update_at,json=updateAt,proto3" json:"update_at" bson:"update_at"` // 更新人 // @gotags: json:"update_by" bson:"update_by" UpdateBy string `protobuf:"bytes,4,opt,name=update_by,json=updateBy,proto3" json:"update_by" bson:"update_by"` // 颁发请求 // @gotags: json:"data" bson:"data" Data *IssueTokenRequest `protobuf:"bytes,5,opt,name=data,proto3" json:"data" bson:"data"` // 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 todo
func NewDefaultToken ¶
func NewDefaultToken() *Token
func (*Token) Descriptor
deprecated
func (*Token) GetAccessToken ¶
func (*Token) GetAccessTokenExpiredAt ¶
func (*Token) GetData ¶
func (x *Token) GetData() *IssueTokenRequest
func (*Token) GetIssueAt ¶
func (*Token) GetRefreshToken ¶
func (*Token) GetRefreshTokenExpiredAt ¶
func (*Token) GetUpdateAt ¶
func (*Token) GetUpdateBy ¶
func (*Token) IsRefreshTokenExpired ¶
func (*Token) ProtoMessage ¶
func (*Token) ProtoMessage()
func (*Token) ProtoReflect ¶
func (x *Token) ProtoReflect() protoreflect.Message
type TokenSet ¶
type TokenSet struct { // 分页时,返回总数量 // @gotags: json:"total" Total int64 `protobuf:"varint,1,opt,name=total,proto3" json:"total"` // 一页的数据 // @gotags: json:"items" Items []*Token `protobuf:"bytes,2,rep,name=items,proto3" json:"items"` // contains filtered or unexported fields }
TokenSet todo
func (*TokenSet) Descriptor
deprecated
func (*TokenSet) ProtoMessage ¶
func (*TokenSet) ProtoMessage()
func (*TokenSet) ProtoReflect ¶
func (x *TokenSet) ProtoReflect() protoreflect.Message
type UnimplementedServiceServer ¶
type UnimplementedServiceServer struct { }
UnimplementedServiceServer must be embedded to have forward compatible implementations.
func (UnimplementedServiceServer) IssueToken ¶
func (UnimplementedServiceServer) IssueToken(context.Context, *IssueTokenRequest) (*Token, error)
func (UnimplementedServiceServer) QueryToken ¶
func (UnimplementedServiceServer) QueryToken(context.Context, *QueryTokenRequest) (*TokenSet, error)
func (UnimplementedServiceServer) RevolkToken ¶
func (UnimplementedServiceServer) RevolkToken(context.Context, *RevolkTokenRequest) (*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(at 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