fix: make file correcrt repo
This commit is contained in:
parent
23d0ce66e9
commit
8a746d9b40
|
@ -121,6 +121,17 @@ message Tokens{
|
|||
repeated TokenResp token = 1;
|
||||
}
|
||||
|
||||
message GetSystemClaimReq{
|
||||
string access_token=1;
|
||||
bool is_expired=2;
|
||||
}
|
||||
|
||||
message GetSystemClaimResp {
|
||||
map<string,string> data = 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 跟 Token 相關的大小事,這次只回應錯誤,以及結果,不統一規範
|
||||
// 錯誤碼應該在 Biz GW 在做回應,另外我這邊取名字比較通用,
|
||||
// access_token -> token , refresh_token -> one_time_token
|
||||
|
@ -141,6 +152,8 @@ service TokenService {
|
|||
rpc GetUserTokensByDeviceID(DoTokenByDeviceIDReq) returns(Tokens);
|
||||
// GetUserTokensByUID 取得目前所對應的 UID 所存在的 Tokens
|
||||
rpc GetUserTokensByUID(QueryTokenByUIDReq) returns(Tokens);
|
||||
// 取得 Claim
|
||||
rpc GetSystemClaimByAccessToken(GetSystemClaimReq) returns(GetSystemClaimResp);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
package tokenservicelogic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"code.30cm.net/digimon/app-cloudep-permission-server/gen_result/pb/permission"
|
||||
"code.30cm.net/digimon/app-cloudep-permission-server/internal/svc"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type GetSystemClaimByAccessTokenLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewGetSystemClaimByAccessTokenLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetSystemClaimByAccessTokenLogic {
|
||||
return &GetSystemClaimByAccessTokenLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
// GetSystemClaimByAccessToken 取得 Claim
|
||||
func (l *GetSystemClaimByAccessTokenLogic) GetSystemClaimByAccessToken(in *permission.GetSystemClaimReq) (*permission.GetSystemClaimResp, error) {
|
||||
claim, err := l.svcCtx.TokenUseCase.ParseSystemClaimsByAccessToken(in.GetAccessToken(), l.svcCtx.Config.Token.Secret, in.GetIsExpired())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &permission.GetSystemClaimResp{
|
||||
Data: claim,
|
||||
}, nil
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
// Code generated by goctl. DO NOT EDIT.
|
||||
// goctl 1.8.1
|
||||
// Source: permission.proto
|
||||
|
||||
package server
|
||||
|
||||
import (
|
||||
"code.30cm.net/digimon/app-cloudep-permission-server/gen_result/pb/permission"
|
||||
"code.30cm.net/digimon/app-cloudep-permission-server/internal/logic/permissionservice"
|
||||
"code.30cm.net/digimon/app-cloudep-permission-server/internal/svc"
|
||||
)
|
||||
|
||||
type PermissionServiceServer struct {
|
||||
svcCtx *svc.ServiceContext
|
||||
permission.UnimplementedPermissionServiceServer
|
||||
}
|
||||
|
||||
func NewPermissionServiceServer(svcCtx *svc.ServiceContext) *PermissionServiceServer {
|
||||
return &PermissionServiceServer{
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
// Code generated by goctl. DO NOT EDIT.
|
||||
// goctl 1.7.3
|
||||
// goctl 1.8.1
|
||||
// Source: permission.proto
|
||||
|
||||
package server
|
||||
|
@ -70,3 +70,9 @@ func (s *TokenServiceServer) GetUserTokensByUID(ctx context.Context, in *permiss
|
|||
l := tokenservicelogic.NewGetUserTokensByUIDLogic(ctx, s.svcCtx)
|
||||
return l.GetUserTokensByUID(in)
|
||||
}
|
||||
|
||||
// 取得 Claim
|
||||
func (s *TokenServiceServer) GetSystemClaimByAccessToken(ctx context.Context, in *permission.GetSystemClaimReq) (*permission.GetSystemClaimResp, error) {
|
||||
l := tokenservicelogic.NewGetSystemClaimByAccessTokenLogic(ctx, s.svcCtx)
|
||||
return l.GetSystemClaimByAccessToken(in)
|
||||
}
|
||||
|
|
|
@ -450,8 +450,12 @@ func (use *TokenUseCase) newToken(ctx context.Context, req *usecase.GenerateToke
|
|||
RefreshCreateAt: now.UnixNano(),
|
||||
UID: req.UID,
|
||||
}
|
||||
initData := make(map[string]string, 0)
|
||||
for k, v := range req.Data {
|
||||
initData[k] = v
|
||||
}
|
||||
// 故意 data 裡面不會有那些已經有的欄位資訊
|
||||
data := NewAdditional(req.Data)
|
||||
data := NewAdditional(initData)
|
||||
data.Set(dt.ID, token.ID)
|
||||
data.Set(dt.Role, req.Role)
|
||||
data.Set(dt.Scope, req.Scope)
|
||||
|
|
Loading…
Reference in New Issue