You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When creating OIDC users, the provider was calling UpdateUserRoles
even with empty roles due to the default schema value, causing the
server error "User Role Field is set in the OIDC configuration".
OIDC users should get their roles exclusively from the OIDC provider's
role mapping, not from explicit API calls. This fix:
- Errors if explicit roles are provided for OIDC users
- Skips role assignment entirely for OIDC users
- Provides clear error messaging about OIDC role behavior
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <[email protected]>
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Unable to update newly created user roles, got error: %s", err))
224
-
return
216
+
217
+
// OIDC users get their roles from the OIDC provider's role mapping
218
+
ifloginType==codersdk.LoginTypeOIDC {
219
+
iflen(roles) >0 {
220
+
resp.Diagnostics.AddError("Configuration Error", "Cannot set explicit roles for OIDC users. OIDC users get their roles from the OIDC provider's role mapping configuration.")
221
+
return
222
+
}
223
+
tflog.Info(ctx, "skipping role assignment for OIDC user (roles come from OIDC provider)")
224
+
} else {
225
+
// For non-OIDC users, set roles explicitly
226
+
tflog.Info(ctx, "updating user roles", map[string]any{
resp.Diagnostics.AddError("Configuration Error", "Cannot set explicit roles for OIDC users. OIDC users get their roles from the OIDC provider's role mapping configuration.")
368
+
return
369
+
}
370
+
tflog.Info(ctx, "skipping role assignment for OIDC user (roles come from OIDC provider)")
371
+
} else {
372
+
// For non-OIDC users, set roles explicitly
373
+
tflog.Info(ctx, "updating user roles", map[string]any{
0 commit comments