MCPcopy Index your code
hub / github.com/coder/coder / externalAuthDeviceByID

Method externalAuthDeviceByID

coderd/externalauth.go:236–257  ·  view source on GitHub ↗

@Summary Get external auth device by ID. @ID get-external-auth-device-by-id @Security CoderSessionToken @Produce json @Tags Git @Param externalauth path string true "Git Provider ID" format(string) @Success 200 {object} codersdk.ExternalAuthDevice @Router /api/v2/external-auth/{externalauth}/device

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

Source from the content-addressed store, hash-verified

234// @Success 200 {object} codersdk.ExternalAuthDevice
235// @Router /api/v2/external-auth/{externalauth}/device [get]
236func (*API) externalAuthDeviceByID(rw http.ResponseWriter, r *http.Request) {
237 config := httpmw.ExternalAuthParam(r)
238 ctx := r.Context()
239
240 if config.DeviceAuth == nil {
241 httpapi.Write(ctx, rw, http.StatusBadRequest, codersdk.Response{
242 Message: "Git auth device flow not supported.",
243 })
244 return
245 }
246
247 deviceAuth, err := config.DeviceAuth.AuthorizeDevice(r.Context())
248 if err != nil {
249 httpapi.Write(r.Context(), rw, http.StatusInternalServerError, codersdk.Response{
250 Message: "Failed to authorize device.",
251 Detail: err.Error(),
252 })
253 return
254 }
255
256 httpapi.Write(ctx, rw, http.StatusOK, deviceAuth)
257}
258
259func (api *API) externalAuthCallback(externalAuthConfig *externalauth.Config) http.HandlerFunc {
260 return func(rw http.ResponseWriter, r *http.Request) {

Callers

nothing calls this directly

Calls 5

ExternalAuthParamFunction · 0.92
WriteFunction · 0.92
AuthorizeDeviceMethod · 0.80
ContextMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected