MCPcopy
hub / github.com/ory/hydra / patchOAuth2Client

Method patchOAuth2Client

client/handler.go:435–471  ·  view source on GitHub ↗

swagger:route PATCH /admin/clients/{id} oAuth2 patchOAuth2Client # Patch OAuth 2.0 Client Patch an existing OAuth 2.0 Client using JSON Patch. If you pass `client_secret` the secret will be updated and returned via the API. This is the only time you will be able to retrieve the client secret, so w

(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

433// Extensions:
434// x-ory-ratelimit-bucket: hydra-admin-high
435func (h *Handler) patchOAuth2Client(w http.ResponseWriter, r *http.Request) {
436 patchJSON, err := io.ReadAll(r.Body)
437 if err != nil {
438 h.r.Writer().WriteError(w, r, err)
439 return
440 }
441
442 id := r.PathValue("id")
443 client, err := h.r.ClientManager().GetConcreteClient(r.Context(), id)
444 if err != nil {
445 h.r.Writer().WriteError(w, r, err)
446 return
447 }
448
449 oldSecret := client.Secret
450
451 client, err = jsonx.ApplyJSONPatch(patchJSON, client, "/id")
452 if err != nil {
453 h.r.Writer().WriteError(w, r, err)
454 return
455 }
456
457 // fix for #2869
458 // GetConcreteClient returns a client with the hashed secret, however updateClient expects
459 // an empty secret if the secret hasn't changed. As such we need to check if the patch has
460 // updated the secret or not
461 if oldSecret == client.Secret {
462 client.Secret = ""
463 }
464
465 if err := h.updateClient(r.Context(), client, h.r.ClientValidator().Validate); err != nil {
466 h.r.Writer().WriteError(w, r, err)
467 return
468 }
469
470 h.r.Writer().Write(w, r, client)
471}
472
473// Paginated OAuth2 Client List Response
474//

Callers

nothing calls this directly

Calls 6

updateClientMethod · 0.95
WriterMethod · 0.65
GetConcreteClientMethod · 0.65
ClientManagerMethod · 0.65
ClientValidatorMethod · 0.65
WriteMethod · 0.45

Tested by

no test coverage detected