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

Method tokenConfig

coderd/apikey.go:501–518  ·  view source on GitHub ↗

@Summary Get token config @ID get-token-config @Security CoderSessionToken @Produce json @Tags General @Param user path string true "User ID, name, or me" @Success 200 {object} codersdk.TokenConfig @Router /api/v2/users/{user}/keys/tokens/tokenconfig [get]

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

Source from the content-addressed store, hash-verified

499// @Success 200 {object} codersdk.TokenConfig
500// @Router /api/v2/users/{user}/keys/tokens/tokenconfig [get]
501func (api *API) tokenConfig(rw http.ResponseWriter, r *http.Request) {
502 user := httpmw.UserParam(r)
503 maxLifetime, err := api.getMaxTokenLifetime(r.Context(), user.ID)
504 if err != nil {
505 httpapi.Write(r.Context(), rw, http.StatusInternalServerError, codersdk.Response{
506 Message: "Failed to get token configuration.",
507 Detail: err.Error(),
508 })
509 return
510 }
511
512 httpapi.Write(
513 r.Context(), rw, http.StatusOK,
514 codersdk.TokenConfig{
515 MaxTokenLifetime: maxLifetime,
516 },
517 )
518}
519
520func (api *API) validateAPIKeyLifetime(ctx context.Context, userID uuid.UUID, lifetime time.Duration) error {
521 if lifetime <= 0 {

Callers

nothing calls this directly

Calls 5

getMaxTokenLifetimeMethod · 0.95
UserParamFunction · 0.92
WriteFunction · 0.92
ContextMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected