From 0021226a60848b9cfa156be067083c412e5de792 Mon Sep 17 00:00:00 2001 From: buptxxb65 <122503929+buptxxb65@users.noreply.github.com> Date: Tue, 17 Jan 2023 17:37:20 +0800 Subject: [PATCH] fix: check the duplicated Application ClientId (#1481) * fix: Check the duplicate ClientId and ClientSecret of Application. * Bug fix --- object/application.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/object/application.go b/object/application.go index b8fd9265..16c129c2 100644 --- a/object/application.go +++ b/object/application.go @@ -287,7 +287,8 @@ func GetMaskedApplications(applications []*Application, userId string) []*Applic func UpdateApplication(id string, application *Application) bool { owner, name := util.GetOwnerAndNameFromId(id) - if getApplication(owner, name) == nil { + oldApplication := getApplication(owner, name) + if oldApplication == nil { return false } @@ -302,6 +303,10 @@ func UpdateApplication(id string, application *Application) bool { } } + if oldApplication.ClientId != application.ClientId && GetApplicationByClientId(application.ClientId) != nil { + return false + } + for _, providerItem := range application.Providers { providerItem.Provider = nil } @@ -325,6 +330,9 @@ func AddApplication(application *Application) bool { if application.ClientSecret == "" { application.ClientSecret = util.GenerateClientSecret() } + if GetApplicationByClientId(application.ClientId) != nil { + return false + } for _, providerItem := range application.Providers { providerItem.Provider = nil }