Skip to content

Conversation

@elibosley
Copy link
Member

@elibosley elibosley commented Aug 15, 2025

Summary by CodeRabbit

  • New Features

    • Added SSO token-based login with UI support; accepts tokens 500+ characters.
    • Improved OIDC redirect handling to respect protocol/host/port and dev proxy, fixing redirects behind reverse proxies.
  • Documentation

    • API docs and images now fully refreshed in the docs site during publishing.
  • Tests

    • Expanded test coverage for redirect URI generation and edge cases.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 15, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Updates OIDC redirect handling to use full request origin, adjusts REST controller to be proxy-aware, and expands tests. Introduces SSO login path in Unraid PHP patch, lowering SSO token-length threshold from 800 to 500 and integrating UI include. Workflow updates fully refresh Docusaurus API docs and images with existence checks.

Changes

Cohort / File(s) Summary
Docs workflow refresh
.github/workflows/create-docusaurus-pr.yml
Rebuilds docs/API directory; clears and copies Markdown; clears images and conditionally copies from two sources with existence checks.
OIDC redirect origin handling
api/src/unraid-api/graph/resolvers/sso/oidc-auth.service.ts, api/src/unraid-api/graph/resolvers/sso/oidc-auth.service.test.ts, api/src/unraid-api/rest/rest.controller.ts
Service signatures change requestHost→requestOrigin; redirect URI constructed from full origin with scheme/port handling and localhost:3000 dev case; REST controller derives origin via forwarded headers; tests expanded for schemes/ports.
SSO token threshold and login flow
api/src/unraid-api/unraid-file-modifier/modifications/patches/sso.patch, api/src/unraid-api/unraid-file-modifier/modifications/sso.modification.ts, api/src/unraid-api/unraid-file-modifier/modifications/__test__/snapshots/.login.php.modified.snapshot.php
Adds verifyUsernamePasswordAndSSO, integrates into login, includes SSO UI hook, and lowers SSO token-length threshold to >500; snapshot updated accordingly.

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant REST as REST Controller
  participant OIDC as OidcAuthService
  participant IdP as OIDC Provider

  Client->>REST: GET /oidc/authorize
  REST->>REST: Derive requestOrigin (proto + host)
  REST->>OIDC: getAuthorizationUrl(providerId, state, requestOrigin)
  OIDC->>OIDC: Build redirectUri from origin or BASE_URL
  OIDC->>IdP: Construct authorization URL
  IdP-->>Client: Redirect to IdP login

  Client->>REST: GET /oidc/callback
  REST->>REST: Derive requestOrigin and fullUrl
  REST->>OIDC: handleCallback(providerId, code, state, requestOrigin, fullUrl)
  OIDC->>IdP: Exchange code for tokens (redirectUri)
  IdP-->>OIDC: Tokens
  OIDC-->>REST: Session/redirect response
  REST-->>Client: Final redirect
Loading
sequenceDiagram
  participant User
  participant PHP as .login.php
  participant System as getent/shadow
  participant RC as rc.unraid-api

  User->>PHP: Submit username/password
  PHP->>System: Verify password hash
  System-->>PHP: Success/Failure
  alt password ok
    PHP-->>User: Login success
  else password fail and len(password) > 500
    PHP->>RC: sso validate-token "<token>"
    RC-->>PHP: JSON output + exit code
    alt valid==true
      PHP-->>User: Login success
    else
      PHP-->>User: Login failure
    end
  else
    PHP-->>User: Login failure
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested reviewers

  • pujitm
  • mdatelle

Poem

A hop, a skip, I fine-tune the trail,
Redirects align with a proxy’s veil.
Tokens now sing at five-hundred-long,
Passwords or SSO—both paths strong.
Docs freshly groomed, images in line—
Thump-thump! says the rabbit: “Deploy time!” 🐇✨

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.


📜 Recent review details

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

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 1e0a54d and e5b71c6.

📒 Files selected for processing (7)
  • .github/workflows/create-docusaurus-pr.yml (1 hunks)
  • api/src/unraid-api/graph/resolvers/sso/oidc-auth.service.test.ts (1 hunks)
  • api/src/unraid-api/graph/resolvers/sso/oidc-auth.service.ts (4 hunks)
  • api/src/unraid-api/rest/rest.controller.ts (2 hunks)
  • api/src/unraid-api/unraid-file-modifier/modifications/__test__/snapshots/.login.php.modified.snapshot.php (1 hunks)
  • api/src/unraid-api/unraid-file-modifier/modifications/patches/sso.patch (1 hunks)
  • api/src/unraid-api/unraid-file-modifier/modifications/sso.modification.ts (1 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/http-endpoints-not-working

🪧 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.
    • 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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

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

CodeRabbit Commands (Invoked using PR/Issue comments)

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

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

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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.

@claude
Copy link

claude bot commented Aug 15, 2025

Claude finished @elibosley's task —— View job


Code Review Analysis

Todo List:

  • Read modified files to understand the changes
  • Analyze diff for critical issues (security, bugs, breaking changes)
  • Provide concise review feedback

Analysis Complete

No critical issues found in changes

The diff shows improvements to OIDC redirect URI handling that properly parse full origins (protocol + host + port) instead of just hostnames. Key changes:

  • oidc-auth.service.ts: Enhanced getRedirectUri() method to parse full URL origins rather than just hostname strings, with proper port handling
  • rest.controller.ts: Updated to pass full request origin (protocol://host) to the auth service instead of just hostname
  • Password length threshold: Reduced from 800 to 500 characters for SSO token detection

All changes appear security-conscious and improve proxy/reverse-proxy compatibility as intended. No authentication bypass, data validation issues, or breaking changes detected in the modified lines.

- Updated the create-docusaurus-pr.yml workflow to ensure that images from both the API and parent docs directories are copied to the appropriate location in the generated documentation. This maintains the directory structure and improves the completeness of the documentation.
- Enhanced the create-docusaurus-pr.yml workflow to cleanly remove old API images and ensure proper copying of images from both the API and parent documentation directories. This update maintains the directory structure and improves the accuracy of the generated documentation.
- Renamed `requestHost` to `requestOrigin` in OidcAuthService methods for clarity.
- Enhanced `getRedirectUri` method to handle full origin URLs, including protocol and non-standard ports.
- Updated tests to reflect changes in redirect URI generation for various scenarios, including localhost and non-localhost hosts.
- Modified RestController to construct request information using protocol and host headers for improved compatibility.
@elibosley elibosley force-pushed the fix/http-endpoints-not-working branch from 5178b9b to 0eb7127 Compare August 15, 2025 16:28
- Updated the password length validation in the SSO login process from 800 to 500 characters to enhance security and prevent potential issues with excessively long tokens.
- Corresponding changes made in the related snapshot and patch files to ensure consistency across the codebase.
@elibosley elibosley merged commit a4ff3c4 into main Aug 15, 2025
8 of 9 checks passed
@elibosley elibosley deleted the fix/http-endpoints-not-working branch August 15, 2025 16:43
@github-actions
Copy link
Contributor

This plugin has been deployed to Cloudflare R2 and is available for testing.
Download it at this URL:

https://preview.dl.unraid.net/unraid-api/tag/PR1587/dynamix.unraid.net.plg

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

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

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 1e0a54d and 0eb7127.

📒 Files selected for processing (4)
  • .github/workflows/create-docusaurus-pr.yml (1 hunks)
  • api/src/unraid-api/graph/resolvers/sso/oidc-auth.service.test.ts (1 hunks)
  • api/src/unraid-api/graph/resolvers/sso/oidc-auth.service.ts (4 hunks)
  • api/src/unraid-api/rest/rest.controller.ts (2 hunks)
🧰 Additional context used
📓 Path-based instructions (7)
**/*.{ts,tsx}

📄 CodeRabbit Inference Engine (CLAUDE.md)

TypeScript source files must use import specifiers with .js extensions for ESM compatibility

Files:

  • api/src/unraid-api/rest/rest.controller.ts
  • api/src/unraid-api/graph/resolvers/sso/oidc-auth.service.ts
  • api/src/unraid-api/graph/resolvers/sso/oidc-auth.service.test.ts
api/src/unraid-api/**

📄 CodeRabbit Inference Engine (CLAUDE.md)

Place new API source files in api/src/unraid-api/ rather than legacy locations

Prefer adding new files to the Nest repo at api/src/unraid-api/ instead of legacy code

Files:

  • api/src/unraid-api/rest/rest.controller.ts
  • api/src/unraid-api/graph/resolvers/sso/oidc-auth.service.ts
  • api/src/unraid-api/graph/resolvers/sso/oidc-auth.service.test.ts
**/*.{ts,tsx,js,jsx,vue}

📄 CodeRabbit Inference Engine (CLAUDE.md)

Avoid unnecessary or obvious comments; only add comments when needed for clarity

Files:

  • api/src/unraid-api/rest/rest.controller.ts
  • api/src/unraid-api/graph/resolvers/sso/oidc-auth.service.ts
  • api/src/unraid-api/graph/resolvers/sso/oidc-auth.service.test.ts
api/**/*.{test,spec}.{ts,tsx,js,jsx}

📄 CodeRabbit Inference Engine (CLAUDE.md)

Prefer not to mock simple dependencies in API tests

Files:

  • api/src/unraid-api/graph/resolvers/sso/oidc-auth.service.test.ts
**/*.{test,spec}.{js,ts,jsx,tsx}

📄 CodeRabbit Inference Engine (CLAUDE.md)

**/*.{test,spec}.{js,ts,jsx,tsx}: General testing: use .rejects.toThrow() without arguments when asserting thrown errors
General testing: focus on behavior, not exact error message wording
General testing: avoid brittle tests tied to non-essential details (exact messages, log formats)
General testing: use mocks as nouns (objects), not verbs (behavioral overuse)

Files:

  • api/src/unraid-api/graph/resolvers/sso/oidc-auth.service.test.ts
api/**/*.{test,spec}.{js,jsx,ts,tsx}

📄 CodeRabbit Inference Engine (.cursor/rules/api-rules.mdc)

api/**/*.{test,spec}.{js,jsx,ts,tsx}: Use Vitest for tests in the api; do not use Jest
Prefer not to mock simple dependencies in tests
For error testing, use .rejects.toThrow() without arguments; avoid asserting exact error messages unless the message format is the subject under test

Files:

  • api/src/unraid-api/graph/resolvers/sso/oidc-auth.service.test.ts
{**/*.test.ts,**/__test__/{components,store}/**/*.ts}

📄 CodeRabbit Inference Engine (.cursor/rules/web-testing-rules.mdc)

{**/*.test.ts,**/__test__/{components,store}/**/*.ts}: Use .rejects.toThrow() without arguments when asserting that async functions throw; avoid checking exact error message strings unless the message format is explicitly under test
Focus tests on observable behavior and outcomes, not implementation details such as exact error messages
Use await nextTick() for DOM update assertions and flushPromises() for complex async chains; always await async operations before asserting
Place module mock declarations (vi.mock) at the top level of the test file to avoid hoisting issues
Use factory functions in vi.mock calls to define mocks and avoid hoisting pitfalls
Use vi.spyOn() to specify return values or behavior of methods under test
Reset/clear mocks between tests using vi.clearAllMocks() (and vi.resetAllMocks() when appropriate) to ensure isolation
Do not rely on Nuxt auto-imports in tests; import required Vue utilities explicitly in test files
Remember that vi.mock calls are hoisted; avoid mixing mock declarations and module mocks incorrectly

Files:

  • api/src/unraid-api/graph/resolvers/sso/oidc-auth.service.test.ts
🧬 Code Graph Analysis (1)
api/src/unraid-api/graph/resolvers/sso/oidc-auth.service.test.ts (1)
api/src/unraid-api/graph/resolvers/sso/oidc-auth.service.ts (1)
  • getRedirectUri (641-675)
🪛 YAMLlint (1.37.1)
.github/workflows/create-docusaurus-pr.yml

[error] 43-43: trailing spaces

(trailing-spaces)


[error] 46-46: trailing spaces

(trailing-spaces)


[error] 50-50: trailing spaces

(trailing-spaces)


[error] 55-55: trailing spaces

(trailing-spaces)

🔇 Additional comments (12)
.github/workflows/create-docusaurus-pr.yml (1)

34-59: The workflow refactoring improves API documentation handling.

The changes correctly implement a complete refresh of API docs by removing old content, recreating directories, and copying from multiple image sources. The logic properly handles both public/images and docs/images directories, which provides better coverage for documentation assets.

api/src/unraid-api/graph/resolvers/sso/oidc-auth.service.ts (5)

39-43: LGTM! Public method signature updated to use requestOrigin.

The method signature change from requestHost to requestOrigin is more descriptive and aligns with the updated redirect URI logic that uses full origin parsing.


49-49: LGTM! Correctly passes requestOrigin to private helper method.

The call to the private getRedirectUri method correctly passes the requestOrigin parameter.


113-118: LGTM! Consistent parameter naming update in handleCallback.

The parameter name change from requestHost to requestOrigin maintains consistency with the getAuthorizationUrl method signature.


126-126: LGTM! Correctly passes requestOrigin to getRedirectUri.

The call correctly passes the updated requestOrigin parameter to the private helper method.


641-670: LGTM! Robust origin-based redirect URI construction.

The updated getRedirectUri method correctly:

  • Parses the full origin URL to extract protocol, hostname, and port
  • Handles port normalization by removing default ports (80 for HTTP, 443 for HTTPS)
  • Provides special handling for localhost:3000 development scenarios
  • Includes proper error handling with fallback to base URL
  • Constructs consistent redirect URIs with the proper callback path

The implementation is more robust than the previous host-based approach and properly handles reverse proxy scenarios.

api/src/unraid-api/graph/resolvers/sso/oidc-auth.service.test.ts (4)

1515-1518: LGTM! Test correctly validates localhost development scenario.

The test properly uses a full URL (http://localhost:3000) as input and verifies the expected callback URI is generated.


1520-1525: LGTM! Test validates non-localhost HTTPS scenario.

The test correctly uses a full HTTPS URL and verifies the proper callback URI construction.


1527-1532: LGTM! Test validates HTTP protocol for non-localhost hosts.

This test case ensures HTTP protocol support works correctly for non-localhost hosts like tower.local, which is important for internal/development environments.


1534-1539: LGTM! Test validates non-standard port handling.

The test correctly verifies that non-standard ports are preserved in the redirect URI, which is essential for proper callback handling in various deployment scenarios.

api/src/unraid-api/rest/rest.controller.ts (2)

78-87: LGTM! Improved origin handling with proper reverse proxy support.

The updated code correctly:

  • Derives protocol from x-forwarded-proto header with fallback to req.protocol or 'http'
  • Extracts host from x-forwarded-host header with fallback to req.headers.host
  • Constructs a proper requestInfo string with protocol and host
  • Passes the requestInfo to the OIDC service instead of just the host

This implementation properly handles reverse proxy scenarios commonly found in production deployments.


134-144: LGTM! Consistent origin handling in callback method.

The callback method correctly applies the same origin construction logic as the authorize method and properly passes the requestInfo parameter to the OIDC service. The fullUrl construction remains unchanged, which is appropriate as it serves a different purpose.

Comment on lines +40 to +59
# Remove old API docs but preserve other folders
rm -rf docs-repo/docs/API/
mkdir -p docs-repo/docs/API
# Copy all markdown files and maintain directory structure
cp -r source-repo/api/docs/public/. docs-repo/docs/API/
# Clean and copy images directory specifically
rm -rf docs-repo/docs/API/images/
mkdir -p docs-repo/docs/API/images
# Copy images from public/images if they exist
if [ -d "source-repo/api/docs/public/images" ]; then
cp -r source-repo/api/docs/public/images/. docs-repo/docs/API/images/
fi
# Also copy any images from the parent docs/images directory
if [ -d "source-repo/api/docs/images" ]; then
cp -r source-repo/api/docs/images/. docs-repo/docs/API/images/
fi
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix trailing whitespaces to address YAMLlint errors.

The static analysis tool detected trailing spaces on multiple lines that should be cleaned up for consistency.

Apply this diff to remove trailing whitespace:

-          # Remove old API docs but preserve other folders
+          # Remove old API docs but preserve other folders
           rm -rf docs-repo/docs/API/
           mkdir -p docs-repo/docs/API
-          
+          
-          # Copy all markdown files and maintain directory structure
+          # Copy all markdown files and maintain directory structure
           cp -r source-repo/api/docs/public/. docs-repo/docs/API/
-          
+          
-          # Clean and copy images directory specifically
+          # Clean and copy images directory specifically
           rm -rf docs-repo/docs/API/images/
           mkdir -p docs-repo/docs/API/images
-          
+          
-          # Copy images from public/images if they exist
+          # Copy images from public/images if they exist
           if [ -d "source-repo/api/docs/public/images" ]; then
             cp -r source-repo/api/docs/public/images/. docs-repo/docs/API/images/
           fi
-          
+          
-          # Also copy any images from the parent docs/images directory
+          # Also copy any images from the parent docs/images directory
           if [ -d "source-repo/api/docs/images" ]; then
             cp -r source-repo/api/docs/images/. docs-repo/docs/API/images/
           fi
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# Remove old API docs but preserve other folders
rm -rf docs-repo/docs/API/
mkdir -p docs-repo/docs/API
# Copy all markdown files and maintain directory structure
cp -r source-repo/api/docs/public/. docs-repo/docs/API/
# Clean and copy images directory specifically
rm -rf docs-repo/docs/API/images/
mkdir -p docs-repo/docs/API/images
# Copy images from public/images if they exist
if [ -d "source-repo/api/docs/public/images" ]; then
cp -r source-repo/api/docs/public/images/. docs-repo/docs/API/images/
fi
# Also copy any images from the parent docs/images directory
if [ -d "source-repo/api/docs/images" ]; then
cp -r source-repo/api/docs/images/. docs-repo/docs/API/images/
fi
# Remove old API docs but preserve other folders
rm -rf docs-repo/docs/API/
mkdir -p docs-repo/docs/API
# Copy all markdown files and maintain directory structure
cp -r source-repo/api/docs/public/. docs-repo/docs/API/
# Clean and copy images directory specifically
rm -rf docs-repo/docs/API/images/
mkdir -p docs-repo/docs/API/images
# Copy images from public/images if they exist
if [ -d "source-repo/api/docs/public/images" ]; then
cp -r source-repo/api/docs/public/images/. docs-repo/docs/API/images/
fi
# Also copy any images from the parent docs/images directory
if [ -d "source-repo/api/docs/images" ]; then
cp -r source-repo/api/docs/images/. docs-repo/docs/API/images/
fi
🧰 Tools
🪛 YAMLlint (1.37.1)

[error] 43-43: trailing spaces

(trailing-spaces)


[error] 46-46: trailing spaces

(trailing-spaces)


[error] 50-50: trailing spaces

(trailing-spaces)


[error] 55-55: trailing spaces

(trailing-spaces)

🤖 Prompt for AI Agents
.github/workflows/create-docusaurus-pr.yml around lines 40 to 59: several lines
contain trailing whitespace triggering YAMLlint errors; remove all trailing
spaces at the ends of lines in this block (including blank lines), ensure
indentation and line endings remain unchanged, and re-run the linter (or git
diff) to confirm no trailing whitespace remains before committing.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants