Skip to content

Commit 126a560

Browse files
committed
fix: remove org assigning from SCIM
SCIM will no longer assign orgs, as it's now handled during OIDC login.
1 parent c330af0 commit 126a560

File tree

2 files changed

+6
-13
lines changed

2 files changed

+6
-13
lines changed

enterprise/coderd/scim.go

+5-13
Original file line numberDiff line numberDiff line change
@@ -217,22 +217,14 @@ func (api *API) scimPostUser(rw http.ResponseWriter, r *http.Request) {
217217
sUser.UserName = codersdk.UsernameFrom(sUser.UserName)
218218
}
219219

220-
// TODO: This is a temporary solution that does not support multi-org
221-
// deployments. This assumption places all new SCIM users into the
222-
// default organization.
223-
//nolint:gocritic
224-
defaultOrganization, err := api.Database.GetDefaultOrganization(dbauthz.AsSystemRestricted(ctx))
225-
if err != nil {
226-
_ = handlerutil.WriteError(rw, err)
227-
return
228-
}
229-
230220
//nolint:gocritic // needed for SCIM
231221
dbUser, err = api.AGPL.CreateUser(dbauthz.AsSystemRestricted(ctx), api.Database, agpl.CreateUserRequest{
232222
CreateUserRequestWithOrgs: codersdk.CreateUserRequestWithOrgs{
233-
Username: sUser.UserName,
234-
Email: email,
235-
OrganizationIDs: []uuid.UUID{defaultOrganization.ID},
223+
Username: sUser.UserName,
224+
Email: email,
225+
// In the multi-org world, SCIM does not assign any orgs. Users will
226+
// be automatically sync'd with the correct organization on login.
227+
OrganizationIDs: []uuid.UUID{},
236228
},
237229
LoginType: database.LoginTypeOIDC,
238230
// Do not send notifications to user admins as SCIM endpoint might be called sequentially to all users.

enterprise/coderd/scim_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ func TestScim(t *testing.T) {
157157
require.Len(t, userRes.Users, 1)
158158
assert.Equal(t, sUser.Emails[0].Value, userRes.Users[0].Email)
159159
assert.Equal(t, sUser.UserName, userRes.Users[0].Username)
160+
assert.Len(t, userRes.Users[0].OrganizationIDs, 0)
160161

161162
// Expect zero notifications (SkipNotifications = true)
162163
require.Empty(t, notifyEnq.Sent)

0 commit comments

Comments
 (0)