MCPcopy
hub / github.com/ory/kratos / getByExternalID

Method getByExternalID

identity/handler.go:433–463  ·  view source on GitHub ↗

swagger:route GET /admin/identities/by/external/{externalID} identity getIdentityByExternalID # Get an Identity by its External ID Return an [identity](https://www.ory.sh/docs/kratos/concepts/identity-user-model) by its external ID. You can optionally include credentials (e.g. social sign in conne

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

Source from the content-addressed store, hash-verified

431// Extensions:
432// x-ory-ratelimit-bucket: kratos-admin-medium
433func (h *Handler) getByExternalID(w http.ResponseWriter, r *http.Request) {
434 externalID := r.PathValue("externalID")
435 if externalID == "" {
436 h.r.Writer().WriteError(w, r, errors.WithStack(herodot.ErrBadRequest.WithReason("The external ID must not be empty.")))
437 return
438 }
439 i, err := h.r.PrivilegedIdentityPool().FindIdentityByExternalID(r.Context(), externalID, ExpandEverything)
440 if err != nil {
441 h.r.Writer().WriteError(w, r, err)
442 return
443 }
444
445 includeCredentials := r.URL.Query()["include_credential"]
446 var declassify []CredentialsType
447 for _, v := range includeCredentials {
448 tc, ok := ParseCredentialsType(v)
449 if ok {
450 declassify = append(declassify, tc)
451 } else {
452 h.r.Writer().WriteError(w, r, errors.WithStack(herodot.ErrBadRequest.WithReasonf("Invalid value `%s` for parameter `include_credential`.", declassify)))
453 return
454 }
455 }
456
457 emit, err := i.WithDeclassifiedCredentials(r.Context(), h.r, declassify)
458 if err != nil {
459 h.r.Writer().WriteError(w, r, err)
460 return
461 }
462 h.r.Writer().Write(w, r, WithCredentialsAndAdminMetadataInJSON(*emit))
463}
464
465// Create Identity Parameters
466//

Callers

nothing calls this directly

Calls 7

ParseCredentialsTypeFunction · 0.85
WriterMethod · 0.65
WriteMethod · 0.45

Tested by

no test coverage detected