Skip to content

Commit c33c452

Browse files
authored
fix: use default org over index [0] for new scim (#12284)
1 parent 0dd126e commit c33c452

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

enterprise/coderd/scim.go

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -200,27 +200,22 @@ func (api *API) scimPostUser(rw http.ResponseWriter, r *http.Request) {
200200
sUser.UserName = httpapi.UsernameFrom(sUser.UserName)
201201
}
202202

203-
var organizationID uuid.UUID
203+
// TODO: This is a temporary solution that does not support multi-org
204+
// deployments. This assumption places all new SCIM users into the
205+
// default organization.
204206
//nolint:gocritic
205-
organizations, err := api.Database.GetOrganizations(dbauthz.AsSystemRestricted(ctx))
207+
defaultOrganization, err := api.Database.GetDefaultOrganization(dbauthz.AsSystemRestricted(ctx))
206208
if err != nil {
207209
_ = handlerutil.WriteError(rw, err)
208210
return
209211
}
210212

211-
if len(organizations) > 0 {
212-
// Add the user to the first organization. Once multi-organization
213-
// support is added, we should enable a configuration map of user
214-
// email to organization.
215-
organizationID = organizations[0].ID
216-
}
217-
218213
//nolint:gocritic // needed for SCIM
219214
dbUser, _, err = api.AGPL.CreateUser(dbauthz.AsSystemRestricted(ctx), api.Database, agpl.CreateUserRequest{
220215
CreateUserRequest: codersdk.CreateUserRequest{
221216
Username: sUser.UserName,
222217
Email: email,
223-
OrganizationID: organizationID,
218+
OrganizationID: defaultOrganization.ID,
224219
},
225220
LoginType: database.LoginTypeOIDC,
226221
})

0 commit comments

Comments
 (0)