MCPcopy Create free account
hub / github.com/ory/hydra / setOidcDynamicClient

Method setOidcDynamicClient

client/handler.go:349–388  ·  view source on GitHub ↗

swagger:route PUT /oauth2/register/{id} oidc setOidcDynamicClient # Set OAuth2 Client using OpenID Dynamic Client Registration This endpoint behaves like the administrative counterpart (`setOAuth2Client`) but is capable of facing the public internet directly to be used by third parties. It impleme

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

Source from the content-addressed store, hash-verified

347// Extensions:
348// x-ory-ratelimit-bucket: hydra-public-high
349func (h *Handler) setOidcDynamicClient(w http.ResponseWriter, r *http.Request) {
350 if err := h.requireDynamicAuth(r); err != nil {
351 h.r.Writer().WriteError(w, r, err)
352 return
353 }
354
355 client, err := h.ValidDynamicAuth(r, r.PathValue("id"))
356 if err != nil {
357 h.r.Writer().WriteError(w, r, err)
358 return
359 }
360
361 var c Client
362 if err := json.NewDecoder(r.Body).Decode(&c); err != nil {
363 h.r.Writer().WriteError(w, r, errors.WithStack(herodot.ErrBadRequest.WithReasonf("Unable to decode the request body. Is it valid JSON?").WithDebug(err.Error())))
364 return
365 }
366
367 if c.Secret != "" {
368 h.r.Writer().WriteError(w, r, errors.WithStack(herodot.ErrForbidden.WithReasonf("It is not allowed to choose your own OAuth2 Client secret.")))
369 return
370 }
371
372 // Regenerate the registration access token
373 token, signature, err := h.r.OAuth2HMACStrategy().GenerateAccessToken(r.Context(), nil)
374 if err != nil {
375 h.r.Writer().WriteError(w, r, err)
376 return
377 }
378 c.RegistrationAccessToken = token
379 c.RegistrationAccessTokenSignature = signature
380
381 c.ID = client.GetID()
382 if err := h.updateClient(r.Context(), &c, h.r.ClientValidator().ValidateDynamicRegistration); err != nil {
383 h.r.Writer().WriteError(w, r, err)
384 return
385 }
386
387 h.r.Writer().Write(w, r, &c)
388}
389
390// Patch OAuth 2.0 Client Parameters
391//

Callers

nothing calls this directly

Calls 12

requireDynamicAuthMethod · 0.95
ValidDynamicAuthMethod · 0.95
updateClientMethod · 0.95
WithDebugMethod · 0.80
WriterMethod · 0.65
DecodeMethod · 0.65
GenerateAccessTokenMethod · 0.65
OAuth2HMACStrategyMethod · 0.65
GetIDMethod · 0.65
ClientValidatorMethod · 0.65
ErrorMethod · 0.45
WriteMethod · 0.45

Tested by

no test coverage detected