Skip to content

fix: check REGISTER_ENABLED before auto-registering OIDC users (#16103) - #16105

Closed
zaviermeekz-cpu wants to merge 4 commits into
infiniflow:mainfrom
zaviermeekz-cpu:fix/oidc-register-check
Closed

zaviermeekz-cpu wants to merge 4 commits into
infiniflow:mainfrom
zaviermeekz-cpu:fix/oidc-register-check

Conversation

@zaviermeekz-cpu

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

The OIDC callback handler automatically creates a new user if the email is not found in the database, even when REGISTER_ENABLED=0. This allows new users to bypass registration restrictions.

This PR adds a check for REGISTER_ENABLED before the user_register call in the OIDC callback. If registration is disabled, the request is rejected with an error.

Type of change

  • Bug Fix

How has this been tested?

  • Manually tested with REGISTER_ENABLED=0: OIDC login for an existing user succeeds; login for a new user fails with "registration_disabled".
  • With REGISTER_ENABLED=1, new users are still created as expected.

Related Issue

Closes #16103

@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. 🐞 bug Something isn't working, pull request that fix bug. labels Jun 16, 2026
@coderabbitai

coderabbitai Bot commented Jun 16, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 8912a2a6-590f-4407-9e8c-5f4c6cf10a7f

📥 Commits

Reviewing files that changed from the base of the PR and between 2c1af18 and 498533c.

📒 Files selected for processing (1)
  • api/apps/restful_apis/user_api.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • api/apps/restful_apis/user_api.py

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.


📝 Walkthrough

Walkthrough

The OAuth callback now checks settings.REGISTER_ENABLED before registering a new user. When registration is disabled, it logs a warning and redirects to /?error=registration_disabled.

Changes

OAuth Registration Gate

Layer / File(s) Summary
REGISTER_ENABLED guard in oauth_callback
api/apps/restful_apis/user_api.py
The callback blocks automatic registration for new OAuth users when settings.REGISTER_ENABLED is false. It logs a warning and redirects to /?error=registration_disabled.

Priority: ➖ Normal

Estimated code review effort: 1 (Trivial) | ~3 minutes

Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 49853

OIDC sign-in now prevents creation of new accounts when registration is disabled while retaining login access for existing users. No concrete current-head merge risk remains.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: checking REGISTER_ENABLED before OIDC auto-registration.
Description check ✅ Passed The description explains the problem, solution, behavior for both setting values, testing, and related issue. It satisfies the required Summary content.
Linked Issues check ✅ Passed The change satisfies issue [#16103]. Existing OIDC users can log in, new users are blocked when REGISTER_ENABLED=0, and registration remains available when it is enabled.
Out of Scope Changes check ✅ Passed The changes are limited to the OIDC registration path and directly support the linked issue. No unrelated changes are present.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

A rabbit checks the setting bright
New OAuth accounts wait tonight
When registration is disabled
The callback stays well-guided
Existing users pass the gate

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@api/apps/restful_apis/user_api.py`:
- Around line 225-227: The registration-disabled rejection path (the check for
`not settings.REGISTER_ENABLED`) is missing audit logging. Add a warning or info
level log statement before the redirect that includes the channel and
email/subject information (when available) to make blocked OIDC registrations
traceable. This ensures compliance with the coding guideline requiring logging
for new flows.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c8a62a0a-2018-4c6c-9dd8-191deb8f4b68

📥 Commits

Reviewing files that changed from the base of the PR and between 6865039 and b9f3a1e.

📒 Files selected for processing (1)
  • api/apps/restful_apis/user_api.py

Comment thread api/apps/restful_apis/user_api.py Resolved
@coderabbitai

coderabbitai Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@6ba3i 6ba3i left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The fix works technically, but REGISTER_ENABLED is the wrong switch for OIDC/OAuth provisioning.
That setting is used for local/public registration, while OIDC provisioning is treated separately. The maintainer discussion in #16103 also points toward restricting OIDC access through groups/roles instead.
With this change, deployments using REGISTER_ENABLED=0 to block public signup but still relying on OIDC JIT provisioning would break.
I’d keep the two policies separate: use IdP/group-role restrictions, or add a dedicated OIDC provisioning setting if needed.Also add regression tests for new vs existing OIDC users with provisioning enabled/disabled.

@6ba3i

6ba3i commented Sep 15, 2026

Copy link
Copy Markdown
Collaborator

overlaps #19651

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

Labels

🐞 bug Something isn't working, pull request that fix bug. size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: OIDC login allows new user registration even when REGISTER_ENABLED=0

3 participants