2024-08-05 09:11:43 +00:00
|
|
|
|
// Code generated by goctl. DO NOT EDIT.
|
|
|
|
|
// Source: permission.proto
|
|
|
|
|
|
|
|
|
|
package server
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
|
|
|
|
|
"ark-permission/gen_result/pb/permission"
|
2024-08-10 01:52:23 +00:00
|
|
|
|
"ark-permission/internal/logic/tokenservice"
|
2024-08-05 09:11:43 +00:00
|
|
|
|
"ark-permission/internal/svc"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type TokenServiceServer struct {
|
|
|
|
|
svcCtx *svc.ServiceContext
|
|
|
|
|
permission.UnimplementedTokenServiceServer
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func NewTokenServiceServer(svcCtx *svc.ServiceContext) *TokenServiceServer {
|
|
|
|
|
return &TokenServiceServer{
|
|
|
|
|
svcCtx: svcCtx,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// NewToken 建立一個新的 Token,例如:AccessToken
|
|
|
|
|
func (s *TokenServiceServer) NewToken(ctx context.Context, in *permission.AuthorizationReq) (*permission.TokenResp, error) {
|
2024-08-10 01:52:23 +00:00
|
|
|
|
l := tokenservicelogic.NewNewTokenLogic(ctx, s.svcCtx)
|
2024-08-05 09:11:43 +00:00
|
|
|
|
return l.NewToken(in)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// RefreshToken 更新目前的token 以及裡面包含的一次性 Token
|
|
|
|
|
func (s *TokenServiceServer) RefreshToken(ctx context.Context, in *permission.RefreshTokenReq) (*permission.RefreshTokenResp, error) {
|
2024-08-10 01:52:23 +00:00
|
|
|
|
l := tokenservicelogic.NewRefreshTokenLogic(ctx, s.svcCtx)
|
2024-08-05 09:11:43 +00:00
|
|
|
|
return l.RefreshToken(in)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// CancelToken 取消 Token,也包含他裡面的 One Time Toke
|
|
|
|
|
func (s *TokenServiceServer) CancelToken(ctx context.Context, in *permission.CancelTokenReq) (*permission.OKResp, error) {
|
2024-08-10 01:52:23 +00:00
|
|
|
|
l := tokenservicelogic.NewCancelTokenLogic(ctx, s.svcCtx)
|
2024-08-05 09:11:43 +00:00
|
|
|
|
return l.CancelToken(in)
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-11 12:21:42 +00:00
|
|
|
|
// ValidationToken 驗證這個 Token 有沒有效
|
|
|
|
|
func (s *TokenServiceServer) ValidationToken(ctx context.Context, in *permission.ValidationTokenReq) (*permission.ValidationTokenResp, error) {
|
|
|
|
|
l := tokenservicelogic.NewValidationTokenLogic(ctx, s.svcCtx)
|
|
|
|
|
return l.ValidationToken(in)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// CancelTokens 取消 Token 從UID 視角,以及 token id 視角出發, UID 登出,底下所有 Device ID 也要登出, Token ID 登出, 所有 UID + Device 都要登出
|
|
|
|
|
func (s *TokenServiceServer) CancelTokens(ctx context.Context, in *permission.DoTokenByUIDReq) (*permission.OKResp, error) {
|
|
|
|
|
l := tokenservicelogic.NewCancelTokensLogic(ctx, s.svcCtx)
|
|
|
|
|
return l.CancelTokens(in)
|
2024-08-05 09:11:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-08-11 12:21:42 +00:00
|
|
|
|
// CancelTokenByDeviceId 取消 Token, 從 Device 視角出發,可以選,登出這個Device 下所有 token ,登出這個Device 下指定token
|
2024-08-06 05:59:24 +00:00
|
|
|
|
func (s *TokenServiceServer) CancelTokenByDeviceId(ctx context.Context, in *permission.DoTokenByDeviceIDReq) (*permission.OKResp, error) {
|
2024-08-10 01:52:23 +00:00
|
|
|
|
l := tokenservicelogic.NewCancelTokenByDeviceIdLogic(ctx, s.svcCtx)
|
2024-08-06 05:59:24 +00:00
|
|
|
|
return l.CancelTokenByDeviceId(in)
|
2024-08-05 09:11:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-08-10 01:52:23 +00:00
|
|
|
|
// GetUserTokensByDeviceId 取得目前所對應的 DeviceID 所存在的 Tokens
|
2024-08-06 05:59:24 +00:00
|
|
|
|
func (s *TokenServiceServer) GetUserTokensByDeviceId(ctx context.Context, in *permission.DoTokenByDeviceIDReq) (*permission.Tokens, error) {
|
2024-08-10 01:52:23 +00:00
|
|
|
|
l := tokenservicelogic.NewGetUserTokensByDeviceIdLogic(ctx, s.svcCtx)
|
2024-08-06 05:59:24 +00:00
|
|
|
|
return l.GetUserTokensByDeviceId(in)
|
2024-08-05 09:11:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-08-10 01:52:23 +00:00
|
|
|
|
// GetUserTokensByUid 取得目前所對應的 UID 所存在的 Tokens
|
|
|
|
|
func (s *TokenServiceServer) GetUserTokensByUid(ctx context.Context, in *permission.QueryTokenByUIDReq) (*permission.Tokens, error) {
|
|
|
|
|
l := tokenservicelogic.NewGetUserTokensByUidLogic(ctx, s.svcCtx)
|
2024-08-06 05:59:24 +00:00
|
|
|
|
return l.GetUserTokensByUid(in)
|
2024-08-05 09:11:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// NewOneTimeToken 建立一次性使用,例如:RefreshToken
|
|
|
|
|
func (s *TokenServiceServer) NewOneTimeToken(ctx context.Context, in *permission.CreateOneTimeTokenReq) (*permission.CreateOneTimeTokenResp, error) {
|
2024-08-10 01:52:23 +00:00
|
|
|
|
l := tokenservicelogic.NewNewOneTimeTokenLogic(ctx, s.svcCtx)
|
2024-08-05 09:11:43 +00:00
|
|
|
|
return l.NewOneTimeToken(in)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// CancelOneTimeToken 取消一次性使用
|
2024-08-10 01:52:23 +00:00
|
|
|
|
func (s *TokenServiceServer) CancelOneTimeToken(ctx context.Context, in *permission.CancelOneTimeTokenReq) (*permission.OKResp, error) {
|
|
|
|
|
l := tokenservicelogic.NewCancelOneTimeTokenLogic(ctx, s.svcCtx)
|
2024-08-05 09:11:43 +00:00
|
|
|
|
return l.CancelOneTimeToken(in)
|
|
|
|
|
}
|