From ea20b6c47daceae86e4063d63447e9e31bc3391c Mon Sep 17 00:00:00 2001 From: Tianxin Dong Date: Tue, 23 Aug 2022 17:45:47 +0800 Subject: [PATCH] Fix: fix signedKey using platform id (#4634) Signed-off-by: FogDong Signed-off-by: FogDong --- pkg/apiserver/domain/model/system_info.go | 1 + pkg/apiserver/domain/service/authentication.go | 3 ++- pkg/apiserver/domain/service/system_info.go | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/pkg/apiserver/domain/model/system_info.go b/pkg/apiserver/domain/model/system_info.go index 4231e33ad..d4eb6a192 100644 --- a/pkg/apiserver/domain/model/system_info.go +++ b/pkg/apiserver/domain/model/system_info.go @@ -32,6 +32,7 @@ const ( // SystemInfo systemInfo model type SystemInfo struct { BaseModel + SignedKey string `json:"signedKey"` InstallID string `json:"installID"` EnableCollection bool `json:"enableCollection"` StatisticInfo StatisticInfo `json:"statisticInfo,omitempty"` diff --git a/pkg/apiserver/domain/service/authentication.go b/pkg/apiserver/domain/service/authentication.go index 3bb08399e..1b15d8e59 100644 --- a/pkg/apiserver/domain/service/authentication.go +++ b/pkg/apiserver/domain/service/authentication.go @@ -58,7 +58,8 @@ const ( GrantTypeRefresh = "refresh" ) -var signedKey = "" +// signedKey is the signed key of JWT +var signedKey string // AuthenticationService is the service of authentication type AuthenticationService interface { diff --git a/pkg/apiserver/domain/service/system_info.go b/pkg/apiserver/domain/service/system_info.go index 45171d227..e184e2188 100644 --- a/pkg/apiserver/domain/service/system_info.go +++ b/pkg/apiserver/domain/service/system_info.go @@ -63,6 +63,7 @@ func (u systemInfoServiceImpl) Get(ctx context.Context) (*model.SystemInfo, erro } return info, nil } + info.SignedKey = rand.String(32) installID := rand.String(16) info.InstallID = installID info.EnableCollection = true @@ -161,7 +162,7 @@ func (u systemInfoServiceImpl) Init(ctx context.Context) error { if err != nil { return err } - signedKey = info.InstallID + signedKey = info.SignedKey _, err = initDexConfig(ctx, u.KubeClient, "http://velaux.com") return err }