fix: check the duplicated Application ClientId (#1481)

* fix: Check the duplicate ClientId and ClientSecret of Application.

* Bug fix
This commit is contained in:
buptxxb65 2023-01-17 17:37:20 +08:00 committed by GitHub
parent 79fc0516dd
commit 0021226a60
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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
}