Skip to content

Commit 956d0cb

Browse files
fix: block creating oidc users when oidc has not been configured (#14064)
1 parent 7a4737c commit 956d0cb

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

coderd/users.go

+7
Original file line numberDiff line numberDiff line change
@@ -464,13 +464,20 @@ func (api *API) postUser(rw http.ResponseWriter, r *http.Request) {
464464
}
465465
loginType = database.LoginTypePassword
466466
case codersdk.LoginTypeOIDC:
467+
if api.OIDCConfig == nil {
468+
httpapi.Write(ctx, rw, http.StatusBadRequest, codersdk.Response{
469+
Message: "You must configure OIDC before creating OIDC users.",
470+
})
471+
return
472+
}
467473
loginType = database.LoginTypeOIDC
468474
case codersdk.LoginTypeGithub:
469475
loginType = database.LoginTypeGithub
470476
default:
471477
httpapi.Write(ctx, rw, http.StatusBadRequest, codersdk.Response{
472478
Message: fmt.Sprintf("Unsupported login type %q for manually creating new users.", req.UserLoginType),
473479
})
480+
return
474481
}
475482

476483
user, _, err := api.CreateUser(ctx, api.Database, CreateUserRequest{

0 commit comments

Comments
 (0)