token

package
v0.0.0-...-23cb155 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 24, 2023 License: MulanPSL-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Service_IssueToken_FullMethodName    = "/keyauth_g7.token.Service/IssueToken"
	Service_RevolkToken_FullMethodName   = "/keyauth_g7.token.Service/RevolkToken"
	Service_ValidateToken_FullMethodName = "/keyauth_g7.token.Service/ValidateToken"
	Service_QueryToken_FullMethodName    = "/keyauth_g7.token.Service/QueryToken"
)
View Source
const (
	AppName = "token"
)

Variables

View Source
var (
	GranteType_name = map[int32]string{
		0: "PASSWORD",
		1: "LADP",
		2: "ACCESS_TOKEN",
		3: "REFRSH_TOKEN",
	}
	GranteType_value = map[string]int32{
		"PASSWORD":     0,
		"LADP":         1,
		"ACCESS_TOKEN": 2,
		"REFRSH_TOKEN": 3,
	}
)

Enum value maps for GranteType.

View Source
var File_apps_token_pb_token_proto protoreflect.FileDescriptor
View Source
var Service_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "keyauth_g7.token.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/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 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 (*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 GranteType

type GranteType int32

授权的类型

const (
	// 通过Paasword授权
	GranteType_PASSWORD GranteType = 0
	// LDAP认证
	GranteType_LADP GranteType = 1
	// 通过ACCESS TOKEN来获取一个 TK, 用户API用户访问(RESTful SDK)
	// 通过一个User Password的Token 来生成一个 ACCESS TOKEN
	// HTTP API 编程访问
	GranteType_ACCESS_TOKEN GranteType = 2
	// 通过REFRESH TOKEN获取令牌
	GranteType_REFRSH_TOKEN GranteType = 3
)

func ParseGranteTypeFromString

func ParseGranteTypeFromString(str string) (GranteType, error)

ParseGranteTypeFromString Parse GranteType from string

func (GranteType) Descriptor

func (GranteType) Descriptor() protoreflect.EnumDescriptor

func (GranteType) Enum

func (x GranteType) Enum() *GranteType

func (GranteType) EnumDescriptor deprecated

func (GranteType) EnumDescriptor() ([]byte, []int)

Deprecated: Use GranteType.Descriptor instead.

func (GranteType) Equal

func (t GranteType) Equal(target GranteType) bool

Equal type compare

func (GranteType) IsIn

func (t GranteType) IsIn(targets ...GranteType) bool

IsIn todo

func (GranteType) MarshalJSON

func (t GranteType) MarshalJSON() ([]byte, error)

MarshalJSON todo

func (GranteType) Number

func (x GranteType) Number() protoreflect.EnumNumber

func (GranteType) String

func (x GranteType) String() string

func (GranteType) Type

func (*GranteType) UnmarshalJSON

func (t *GranteType) UnmarshalJSON(b []byte) error

UnmarshalJSON todo

type IssueTokenRequest

type IssueTokenRequest struct {

	// 授权类型
	// @gotags: json:"grante_type" bson:"grante_type"
	GranteType GranteType `` /* 134-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) GetGranteType

func (x *IssueTokenRequest) GetGranteType() GranteType

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 *request.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() *request.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 NewToken

func NewToken(req *IssueTokenRequest, expiredDuration time.Duration) *Token

func (*Token) Descriptor deprecated

func (*Token) Descriptor() ([]byte, []int)

Deprecated: Use Token.ProtoReflect.Descriptor instead.

func (*Token) Extend

func (t *Token) Extend(expiredDuration time.Duration)

func (*Token) GetAccessToken

func (x *Token) GetAccessToken() string

func (*Token) GetAccessTokenExpiredAt

func (x *Token) GetAccessTokenExpiredAt() int64

func (*Token) GetData

func (x *Token) GetData() *IssueTokenRequest

func (*Token) GetIssueAt

func (x *Token) GetIssueAt() int64

func (*Token) GetMeta

func (x *Token) GetMeta() map[string]string

func (*Token) GetRefreshToken

func (x *Token) GetRefreshToken() string

func (*Token) GetRefreshTokenExpiredAt

func (x *Token) GetRefreshTokenExpiredAt() int64

func (*Token) GetUpdateAt

func (x *Token) GetUpdateAt() int64

func (*Token) GetUpdateBy

func (x *Token) GetUpdateBy() string

func (*Token) IsRefreshTokenExpired

func (t *Token) IsRefreshTokenExpired() bool

func (*Token) ProtoMessage

func (*Token) ProtoMessage()

func (*Token) ProtoReflect

func (x *Token) ProtoReflect() protoreflect.Message

func (*Token) Reset

func (x *Token) Reset()

func (*Token) String

func (x *Token) String() string

func (*Token) Validate

func (t *Token) Validate() error

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) Descriptor() ([]byte, []int)

Deprecated: Use TokenSet.ProtoReflect.Descriptor instead.

func (*TokenSet) GetItems

func (x *TokenSet) GetItems() []*Token

func (*TokenSet) GetTotal

func (x *TokenSet) GetTotal() int64

func (*TokenSet) ProtoMessage

func (*TokenSet) ProtoMessage()

func (*TokenSet) ProtoReflect

func (x *TokenSet) ProtoReflect() protoreflect.Message

func (*TokenSet) Reset

func (x *TokenSet) Reset()

func (*TokenSet) String

func (x *TokenSet) String() string

type UnimplementedServiceServer

type UnimplementedServiceServer struct {
}

UnimplementedServiceServer must be embedded to have forward compatible implementations.

func (UnimplementedServiceServer) IssueToken

func (UnimplementedServiceServer) QueryToken

func (UnimplementedServiceServer) RevolkToken

func (UnimplementedServiceServer) ValidateToken

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL