Skip to content

fix(server): oidc registration #12723

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 5, 2025
Merged

fix(server): oidc registration #12723

merged 1 commit into from
Jun 5, 2025

Conversation

forehalo
Copy link
Member

@forehalo forehalo commented Jun 5, 2025

close #12707

Summary by CodeRabbit

  • Bug Fixes
    • Improved reliability of OIDC provider setup, ensuring consistent initialization regardless of configuration fetch outcomes.

@graphite-app graphite-app bot requested review from a team June 5, 2025 08:59
Copy link

coderabbitai bot commented Jun 5, 2025

Walkthrough

The control flow in the OIDC provider's setup validation was modified so that super.setup() is always called after attempting to validate the OIDC configuration, regardless of whether the configuration fetch and parsing succeed. The check for provider configuration was also changed to use super.configured instead of this.configured.

Changes

File(s) Change Summary
packages/backend/server/src/plugins/oauth/providers/oidc.ts Refactored the setup validation logic: always calls super.setup() after validation; changed configuration check from this.configured to super.configured.

Sequence Diagram(s)

sequenceDiagram
    participant OIDCProvider
    participant SuperClass

    OIDCProvider->OIDCProvider: setup()
    OIDCProvider->OIDCProvider: validate()
    OIDCProvider->OIDCProvider: Attempt to fetch OIDC config
    alt Fetch succeeds
        OIDCProvider->OIDCProvider: Parse configuration
    else Fetch fails
        OIDCProvider->OIDCProvider: Handle error
    end
    OIDCProvider->SuperClass: setup()
Loading

Assessment against linked issues

Objective Addressed Explanation
Ensure OIDC provider setup is correctly validated and initialized so that OIDC login option appears after update (12707)

Assessment against linked issues: Out-of-scope changes

No out-of-scope changes found.

Suggested labels

app:server

Poem

A hop, a skip, a clever tweak,
OIDC now works as sleek!
With setup called both win and fail,
The login button’s on the trail.
Bugs be gone, let rabbits cheer—
OAuth flows are crystal clear!
🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d6a26b8 and 9c3bf59.

📒 Files selected for processing (1)
  • packages/backend/server/src/plugins/oauth/providers/oidc.ts (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (56)
  • GitHub Check: test-build-mobile-app / build-ios-web
  • GitHub Check: test-build-mobile-app / build-android-web
  • GitHub Check: y-octo binding test on aarch64-pc-windows-msvc
  • GitHub Check: y-octo binding test on aarch64-unknown-linux-gnu
  • GitHub Check: y-octo binding test on x86_64-pc-windows-msvc
  • GitHub Check: y-octo binding test on x86_64-unknown-linux-gnu
  • GitHub Check: y-octo binding test on aarch64-apple-darwin
  • GitHub Check: y-octo binding test on x86_64-apple-darwin
  • GitHub Check: Run native tests
  • GitHub Check: E2E BlockSuite Test (8)
  • GitHub Check: E2E BlockSuite Test (7)
  • GitHub Check: E2E Mobile Test (5)
  • GitHub Check: E2E BlockSuite Test (10)
  • GitHub Check: E2E BlockSuite Test (9)
  • GitHub Check: E2E BlockSuite Test (6)
  • GitHub Check: E2E BlockSuite Cross Browser Test (2, firefox)
  • GitHub Check: E2E BlockSuite Test (5)
  • GitHub Check: E2E BlockSuite Test (4)
  • GitHub Check: E2E BlockSuite Test (3)
  • GitHub Check: E2E Mobile Test (2)
  • GitHub Check: E2E BlockSuite Cross Browser Test (1, webkit)
  • GitHub Check: E2E Mobile Test (1)
  • GitHub Check: E2E BlockSuite Test (1)
  • GitHub Check: E2E BlockSuite Test (2)
  • GitHub Check: E2E Mobile Test (3)
  • GitHub Check: E2E Mobile Test (4)
  • GitHub Check: Build AFFiNE native (aarch64-pc-windows-msvc)
  • GitHub Check: E2E BlockSuite Cross Browser Test (2, chromium)
  • GitHub Check: E2E BlockSuite Cross Browser Test (1, firefox)
  • GitHub Check: E2E BlockSuite Cross Browser Test (2, webkit)
  • GitHub Check: E2E BlockSuite Cross Browser Test (1, chromium)
  • GitHub Check: E2E Test (3)
  • GitHub Check: E2E Test (7)
  • GitHub Check: Lint Rust
  • GitHub Check: Build AFFiNE native (x86_64-pc-windows-msvc)
  • GitHub Check: E2E Test (6)
  • GitHub Check: Typecheck
  • GitHub Check: E2E Test (9)
  • GitHub Check: E2E Test (10)
  • GitHub Check: E2E Test (5)
  • GitHub Check: E2E Test (8)
  • GitHub Check: E2E Test (1)
  • GitHub Check: Analyze (typescript, blocksuite)
  • GitHub Check: E2E Test (4)
  • GitHub Check: E2E Test (2)
  • GitHub Check: Analyze (javascript, affine)
  • GitHub Check: Analyze (typescript, affine)
  • GitHub Check: fuzzing
  • GitHub Check: Analyze (javascript, blocksuite)
  • GitHub Check: loom thread test
  • GitHub Check: Build @affine/electron renderer
  • GitHub Check: Build AFFiNE native (aarch64-apple-darwin)
  • GitHub Check: Build AFFiNE native (x86_64-unknown-linux-gnu)
  • GitHub Check: Build AFFiNE native (x86_64-apple-darwin)
  • GitHub Check: Build Server native
  • GitHub Check: Lint
🔇 Additional comments (2)
packages/backend/server/src/plugins/oauth/providers/oidc.ts (2)

63-63: Good fix for initialization dependency issue.

Changing from this.configured to super.configured resolves a circular dependency problem. The original this.configured (line 55-57) checks if this.#endpoints !== null, but #endpoints is set inside this very validation logic, creating a chicken-and-egg scenario during initialization.


84-84: Ensure parent setup is always called regardless of OIDC configuration success.

Moving super.setup() outside the conditional block ensures the parent OAuth provider setup completes even if OIDC configuration validation fails. This is the correct approach as the base provider functionality should be initialized independently of OIDC-specific configuration.

✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Member Author

forehalo commented Jun 5, 2025


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@forehalo forehalo enabled auto-merge (squash) June 5, 2025 09:02
Copy link

codecov bot commented Jun 5, 2025

Codecov Report

Attention: Patch coverage is 66.66667% with 1 line in your changes missing coverage. Please review.

Project coverage is 55.85%. Comparing base (d6a26b8) to head (9c3bf59).
Report is 1 commits behind head on canary.

Files with missing lines Patch % Lines
...backend/server/src/plugins/oauth/providers/oidc.ts 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           canary   #12723      +/-   ##
==========================================
- Coverage   55.95%   55.85%   -0.10%     
==========================================
  Files        2653     2653              
  Lines      125273   125274       +1     
  Branches    19887    19822      -65     
==========================================
- Hits        70102    69978     -124     
- Misses      52865    53129     +264     
+ Partials     2306     2167     -139     
Flag Coverage Δ
server-test 79.04% <66.66%> (-0.72%) ⬇️
unittest 31.61% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@forehalo forehalo merged commit 71be1d4 into canary Jun 5, 2025
116 checks passed
@forehalo forehalo deleted the 61/oidc-fix branch June 5, 2025 09:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

[Bug]: OIDC missing with update to 0.22.1 self-hosted
2 participants