Skip to content

Commit

Permalink
on delete client, check that the apiSpec have defined an oauth manager (
Browse files Browse the repository at this point in the history
TykTechnologies#2944)

as reported in TykTechnologies#2940 on delete oauth client first we must check that the ApiSpec have a valid oauthManager loaded, in order to do so was added a validation to check that `apiSpec.OAuthManager` is not null
  • Loading branch information
sredxny authored Mar 20, 2020
1 parent 596b9e5 commit fbb6d87
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions gateway/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -1876,25 +1876,29 @@ func handleDeleteOAuthClient(keyName, apiID string) (interface{}, int) {
return apiError("OAuth Client ID not found"), http.StatusNotFound
}

err := apiSpec.OAuthManager.OsinServer.Storage.DeleteClient(storageID, apiSpec.OrgID, true)
if err != nil {
return apiError("Delete failed"), http.StatusInternalServerError
}
if apiSpec.OAuthManager != nil{
err := apiSpec.OAuthManager.OsinServer.Storage.DeleteClient(storageID,apiSpec.OrgID, true)
if err != nil {
return apiError("Delete failed"), http.StatusInternalServerError
}

statusObj := apiModifyKeySuccess{
Key: keyName,
Status: "ok",
Action: "deleted",
}
statusObj := apiModifyKeySuccess{
Key: keyName,
Status: "ok",
Action: "deleted",
}

log.WithFields(logrus.Fields{
"prefix": "api",
"apiID": apiID,
"status": "ok",
"client": keyName,
}).Info("Deleted OAuth client")
log.WithFields(logrus.Fields{
"prefix": "api",
"apiID": apiID,
"status": "ok",
"client": keyName,
}).Info("Deleted OAuth client")

return statusObj, http.StatusOK
return statusObj, http.StatusOK
}

return apiError("OAuth Client ID not found"), http.StatusNotFound
}

const oAuthNotPropagatedErr = "OAuth client list isn't available or hasn't been propagated yet."
Expand Down

0 comments on commit fbb6d87

Please sign in to comment.