feat: hash client secret
This commit is contained in:
@ -79,9 +79,15 @@ func (h *ApiServicesHandler) Add(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hashSecret, err := util.HashPassword(clientSecret)
|
||||||
|
if err != nil {
|
||||||
|
web.Error(w, "failed to create client secret", http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
service, err := h.repo.CreateApiService(r.Context(), repository.CreateApiServiceParams{
|
service, err := h.repo.CreateApiService(r.Context(), repository.CreateApiServiceParams{
|
||||||
ClientID: clientId,
|
ClientID: clientId,
|
||||||
ClientSecret: clientSecret,
|
ClientSecret: hashSecret,
|
||||||
Name: req.Name,
|
Name: req.Name,
|
||||||
RedirectUris: req.RedirectUris,
|
RedirectUris: req.RedirectUris,
|
||||||
Scopes: req.Scopes,
|
Scopes: req.Scopes,
|
||||||
@ -94,6 +100,8 @@ func (h *ApiServicesHandler) Add(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
||||||
|
|
||||||
|
service.ClientSecret = clientSecret
|
||||||
|
|
||||||
encoder := json.NewEncoder(w)
|
encoder := json.NewEncoder(w)
|
||||||
if err := encoder.Encode(service); err != nil {
|
if err := encoder.Encode(service); err != nil {
|
||||||
web.Error(w, "failed to encode response", http.StatusInternalServerError)
|
web.Error(w, "failed to encode response", http.StatusInternalServerError)
|
||||||
|
Reference in New Issue
Block a user