126 lines
6.4 KiB
Go
126 lines
6.4 KiB
Go
|
// Code generated by goctl. DO NOT EDIT.
|
|||
|
// Source: permission.proto
|
|||
|
|
|||
|
package tokenservice
|
|||
|
|
|||
|
import (
|
|||
|
"context"
|
|||
|
|
|||
|
"ark-permission/gen_result/pb/permission"
|
|||
|
|
|||
|
"github.com/zeromicro/go-zero/zrpc"
|
|||
|
"google.golang.org/grpc"
|
|||
|
)
|
|||
|
|
|||
|
type (
|
|||
|
AuthorizationReq = permission.AuthorizationReq
|
|||
|
CancelOneTimeTokenReq = permission.CancelOneTimeTokenReq
|
|||
|
CancelTokenReq = permission.CancelTokenReq
|
|||
|
CreateOneTimeTokenReq = permission.CreateOneTimeTokenReq
|
|||
|
CreateOneTimeTokenResp = permission.CreateOneTimeTokenResp
|
|||
|
DoTokenByDeviceIDReq = permission.DoTokenByDeviceIDReq
|
|||
|
DoTokenByUIDReq = permission.DoTokenByUIDReq
|
|||
|
OKResp = permission.OKResp
|
|||
|
QueryTokenByUIDReq = permission.QueryTokenByUIDReq
|
|||
|
RefreshTokenReq = permission.RefreshTokenReq
|
|||
|
RefreshTokenResp = permission.RefreshTokenResp
|
|||
|
Token = permission.Token
|
|||
|
TokenResp = permission.TokenResp
|
|||
|
Tokens = permission.Tokens
|
|||
|
ValidationTokenReq = permission.ValidationTokenReq
|
|||
|
ValidationTokenResp = permission.ValidationTokenResp
|
|||
|
|
|||
|
TokenService interface {
|
|||
|
// NewToken 建立一個新的 Token,例如:AccessToken
|
|||
|
NewToken(ctx context.Context, in *AuthorizationReq, opts ...grpc.CallOption) (*TokenResp, error)
|
|||
|
// RefreshToken 更新目前的token 以及裡面包含的一次性 Token
|
|||
|
RefreshToken(ctx context.Context, in *RefreshTokenReq, opts ...grpc.CallOption) (*RefreshTokenResp, error)
|
|||
|
// CancelToken 取消 Token,也包含他裡面的 One Time Toke
|
|||
|
CancelToken(ctx context.Context, in *CancelTokenReq, opts ...grpc.CallOption) (*OKResp, error)
|
|||
|
// ValidationToken 驗證這個 Token 有沒有效
|
|||
|
ValidationToken(ctx context.Context, in *ValidationTokenReq, opts ...grpc.CallOption) (*ValidationTokenResp, error)
|
|||
|
// CancelTokens 取消 Token 從UID 視角,以及 token id 視角出發, UID 登出,底下所有 Device ID 也要登出, Token ID 登出, 所有 UID + Device 都要登出
|
|||
|
CancelTokens(ctx context.Context, in *DoTokenByUIDReq, opts ...grpc.CallOption) (*OKResp, error)
|
|||
|
// CancelTokenByDeviceId 取消 Token, 從 Device 視角出發,可以選,登出這個Device 下所有 token ,登出這個Device 下指定token
|
|||
|
CancelTokenByDeviceId(ctx context.Context, in *DoTokenByDeviceIDReq, opts ...grpc.CallOption) (*OKResp, error)
|
|||
|
// GetUserTokensByDeviceId 取得目前所對應的 DeviceID 所存在的 Tokens
|
|||
|
GetUserTokensByDeviceId(ctx context.Context, in *DoTokenByDeviceIDReq, opts ...grpc.CallOption) (*Tokens, error)
|
|||
|
// GetUserTokensByUid 取得目前所對應的 UID 所存在的 Tokens
|
|||
|
GetUserTokensByUid(ctx context.Context, in *QueryTokenByUIDReq, opts ...grpc.CallOption) (*Tokens, error)
|
|||
|
// NewOneTimeToken 建立一次性使用,例如:RefreshToken
|
|||
|
NewOneTimeToken(ctx context.Context, in *CreateOneTimeTokenReq, opts ...grpc.CallOption) (*CreateOneTimeTokenResp, error)
|
|||
|
// CancelOneTimeToken 取消一次性使用
|
|||
|
CancelOneTimeToken(ctx context.Context, in *CancelOneTimeTokenReq, opts ...grpc.CallOption) (*OKResp, error)
|
|||
|
}
|
|||
|
|
|||
|
defaultTokenService struct {
|
|||
|
cli zrpc.Client
|
|||
|
}
|
|||
|
)
|
|||
|
|
|||
|
func NewTokenService(cli zrpc.Client) TokenService {
|
|||
|
return &defaultTokenService{
|
|||
|
cli: cli,
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
// NewToken 建立一個新的 Token,例如:AccessToken
|
|||
|
func (m *defaultTokenService) NewToken(ctx context.Context, in *AuthorizationReq, opts ...grpc.CallOption) (*TokenResp, error) {
|
|||
|
client := permission.NewTokenServiceClient(m.cli.Conn())
|
|||
|
return client.NewToken(ctx, in, opts...)
|
|||
|
}
|
|||
|
|
|||
|
// RefreshToken 更新目前的token 以及裡面包含的一次性 Token
|
|||
|
func (m *defaultTokenService) RefreshToken(ctx context.Context, in *RefreshTokenReq, opts ...grpc.CallOption) (*RefreshTokenResp, error) {
|
|||
|
client := permission.NewTokenServiceClient(m.cli.Conn())
|
|||
|
return client.RefreshToken(ctx, in, opts...)
|
|||
|
}
|
|||
|
|
|||
|
// CancelToken 取消 Token,也包含他裡面的 One Time Toke
|
|||
|
func (m *defaultTokenService) CancelToken(ctx context.Context, in *CancelTokenReq, opts ...grpc.CallOption) (*OKResp, error) {
|
|||
|
client := permission.NewTokenServiceClient(m.cli.Conn())
|
|||
|
return client.CancelToken(ctx, in, opts...)
|
|||
|
}
|
|||
|
|
|||
|
// ValidationToken 驗證這個 Token 有沒有效
|
|||
|
func (m *defaultTokenService) ValidationToken(ctx context.Context, in *ValidationTokenReq, opts ...grpc.CallOption) (*ValidationTokenResp, error) {
|
|||
|
client := permission.NewTokenServiceClient(m.cli.Conn())
|
|||
|
return client.ValidationToken(ctx, in, opts...)
|
|||
|
}
|
|||
|
|
|||
|
// CancelTokens 取消 Token 從UID 視角,以及 token id 視角出發, UID 登出,底下所有 Device ID 也要登出, Token ID 登出, 所有 UID + Device 都要登出
|
|||
|
func (m *defaultTokenService) CancelTokens(ctx context.Context, in *DoTokenByUIDReq, opts ...grpc.CallOption) (*OKResp, error) {
|
|||
|
client := permission.NewTokenServiceClient(m.cli.Conn())
|
|||
|
return client.CancelTokens(ctx, in, opts...)
|
|||
|
}
|
|||
|
|
|||
|
// CancelTokenByDeviceId 取消 Token, 從 Device 視角出發,可以選,登出這個Device 下所有 token ,登出這個Device 下指定token
|
|||
|
func (m *defaultTokenService) CancelTokenByDeviceId(ctx context.Context, in *DoTokenByDeviceIDReq, opts ...grpc.CallOption) (*OKResp, error) {
|
|||
|
client := permission.NewTokenServiceClient(m.cli.Conn())
|
|||
|
return client.CancelTokenByDeviceId(ctx, in, opts...)
|
|||
|
}
|
|||
|
|
|||
|
// GetUserTokensByDeviceId 取得目前所對應的 DeviceID 所存在的 Tokens
|
|||
|
func (m *defaultTokenService) GetUserTokensByDeviceId(ctx context.Context, in *DoTokenByDeviceIDReq, opts ...grpc.CallOption) (*Tokens, error) {
|
|||
|
client := permission.NewTokenServiceClient(m.cli.Conn())
|
|||
|
return client.GetUserTokensByDeviceId(ctx, in, opts...)
|
|||
|
}
|
|||
|
|
|||
|
// GetUserTokensByUid 取得目前所對應的 UID 所存在的 Tokens
|
|||
|
func (m *defaultTokenService) GetUserTokensByUid(ctx context.Context, in *QueryTokenByUIDReq, opts ...grpc.CallOption) (*Tokens, error) {
|
|||
|
client := permission.NewTokenServiceClient(m.cli.Conn())
|
|||
|
return client.GetUserTokensByUid(ctx, in, opts...)
|
|||
|
}
|
|||
|
|
|||
|
// NewOneTimeToken 建立一次性使用,例如:RefreshToken
|
|||
|
func (m *defaultTokenService) NewOneTimeToken(ctx context.Context, in *CreateOneTimeTokenReq, opts ...grpc.CallOption) (*CreateOneTimeTokenResp, error) {
|
|||
|
client := permission.NewTokenServiceClient(m.cli.Conn())
|
|||
|
return client.NewOneTimeToken(ctx, in, opts...)
|
|||
|
}
|
|||
|
|
|||
|
// CancelOneTimeToken 取消一次性使用
|
|||
|
func (m *defaultTokenService) CancelOneTimeToken(ctx context.Context, in *CancelOneTimeTokenReq, opts ...grpc.CallOption) (*OKResp, error) {
|
|||
|
client := permission.NewTokenServiceClient(m.cli.Conn())
|
|||
|
return client.CancelOneTimeToken(ctx, in, opts...)
|
|||
|
}
|