Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: add proper OIDC user role validation#247

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
angrycub wants to merge4 commits intomainfromfix/oidc-user-roles-empty-list

Conversation

@angrycub
Copy link

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 withClaude Code

ethanndickson reacted with thumbs up emojiethanndickson reacted with heart emoji
When creating OIDC users, the provider was calling UpdateUserRoleseven with empty roles due to the default schema value, causing theserver error "User Role Field is set in the OIDC configuration".OIDC users should get their roles exclusively from the OIDC provider'srole 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 <noreply@anthropic.com>
@angrycubangrycub self-assigned thisAug 15, 2025
@angrycubangrycub added the goPull requests that update Go code labelAug 15, 2025
Copy link
Member

@ethanndicksonethanndicksonAug 15, 2025
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I think we need to updateRead as well here, right? I don't have a Coder deployment w/ an IDP handy*, but I assume if you gave the user managed by Terraform roles via OIDC, Terraform would complain about config drift on every subsequent apply.

*For the same reason, we probably won't be able to have a test for this :( All our provider tests use a containerized coder, and adding a fake IDP for those tests sounds painful.

blink-sobotand others added3 commitsAugust 15, 2025 15:20
Update the Read function to not populate roles from server response for OIDC users.This prevents Terraform from detecting config drift when OIDC users have rolesassigned by the OIDC provider but an empty roles list in the Terraform config.Addresses review comment about config drift in PR#247.Co-authored-by: angrycub <464492+angrycub@users.noreply.github.com>
Update OIDC user role handling to use cleaner Go style:- Use negative conditions (loginType != codersdk.LoginTypeOIDC) for better readability- Simplify comments to be more concise and inline- Maintain all existing validation logic and functionalityCo-authored-by: angrycub <464492+angrycub@users.noreply.github.com>
Fix formatting issues found by go fmt, specifically the closing braceplacement in the ImportState function.Co-authored-by: angrycub <464492+angrycub@users.noreply.github.com>
@angrycubangrycub marked this pull request as ready for reviewAugust 15, 2025 21:07
@ethanndickson
Copy link
Member

Unfortunately, this won't work, as the API rejects user role updates based off:

if user.LoginType == database.LoginTypeOIDC && api.IDPSync.SiteRoleSyncEnabled()

Since it's possible to have an OIDC user who's roles are managed via the API, we'll instead go with a slightly different approach (in#250). That approach is similar to what we offer formembers on thegroup resource.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@ethanndicksonethanndicksonAwaiting requested review from ethanndickson

Assignees

@angrycubangrycub

Labels

goPull requests that update Go code

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@angrycub@ethanndickson

[8]ページ先頭

©2009-2025 Movatter.jp