Skip to content

sso fallback fix - #3793

Merged
Baalmart merged 5 commits into
stagingfrom
device-serial
Jul 11, 2026
Merged

sso fallback fix#3793
Baalmart merged 5 commits into
stagingfrom
device-serial

Conversation

@OlukaGibson

@OlukaGibson OlukaGibson commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Summary of Changes (What does this PR do?)

  • Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

Status of maturity (all need to be checked before merging):

  • I've tested this locally
  • I consider this code done
  • This change ready to hit production in its current state
  • The title of the PR states what changed and the related issues number (used for the release note).
  • I've included issue number in the "Closes #ISSUE-NUMBER" part of the "What are the relevant tickets?" section to link the issue.
  • I've updated corresponding documentation for the changes in this PR.
  • I have written unit and/or e2e tests for my change(s).

How should this be manually tested?

  • Please include the steps to be done inorder to setup and test this PR.

What are the relevant tickets?

Screenshots (optional)

Summary by CodeRabbit

  • Visual Improvements

    • Updated 3D device scenes to use a specific HDRI for lighting and background to improve visual consistency.
  • Bug Fixes

    • Improved authentication initialization by auto-correcting the app’s public URL and providing a fallback secret when missing.
    • Updated the authentication API route to compute and apply the correct runtime URL based on forwarded request headers.
  • Configuration

    • Refined environment detection and API endpoint selection with dynamic runtime settings for more accurate dev/staging/prod behavior.

@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@OlukaGibson, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 6 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: eddc0cd5-96a3-4f42-9da4-c0c1c57efa88

📥 Commits

Reviewing files that changed from the base of the PR and between 4e7faf8 and 028d11f.

📒 Files selected for processing (3)
  • src/beacon/app/api/auth/[...nextauth]/route.ts
  • src/beacon/lib/auth.ts
  • src/beacon/lib/config.js
📝 Walkthrough

Walkthrough

The 3D device model scenes now load a specific HDRI file. Runtime environment detection and API URL selection were rewritten, exported configuration values became dynamic getters, and NextAuth now normalizes fallback settings and request-derived URLs.

Changes

3D Scene Environment

Layer / File(s) Summary
HDRI environment configuration
src/beacon/components/device-model-3d-inner.tsx, src/beacon/components/device-model-3d.tsx
Both device model canvases use /hdri/potsdamer_platz_1k.hdr through the Environment component’s files prop.

Runtime Configuration and Authentication

Layer / File(s) Summary
Dynamic environment and API configuration
src/beacon/lib/config.js
Environment detection, Beacon and AirQo Platform API URL selection, and exported configuration properties now resolve dynamically.
NextAuth runtime configuration
src/beacon/lib/auth.ts, src/beacon/app/api/auth/[...nextauth]/route.ts
NextAuth receives fallback URL and secret values when unset, and derives non-local request URLs from forwarded headers before handling requests.

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related PRs

Suggested reviewers: Codebmk, Baalmart, OchiengPaul442

Poem

City preset yields to HDRI light,
Runtime URLs now resolve right.
Auth follows headers through the night,
Dynamic settings keep the flow in sight.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title matches the auth fallback focus of the changes, though it is broader than the specific NextAuth/config updates.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch device-serial

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (1)
  • JIRA integration encountered authorization issues. Please disconnect and reconnect the integration in the CodeRabbit UI.

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

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: 2

🤖 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 `@src/beacon/components/device-model-3d-inner.tsx`:
- Line 152: Update the Environment component in the device model 3D component to
construct the HDRI URL using the configured application base path rather than
the root-relative "/hdri/potsdamer_platz_1k.hdr" value, ensuring the asset
resolves correctly under basePath deployments.

In `@src/beacon/lib/auth.ts`:
- Around line 11-18: Remove the hardcoded NEXTAUTH_SECRET fallback from the
module initialization in auth.ts so production reaches the existing
missing-secret validation in options.ts; require NEXTAUTH_SECRET from the
environment, or load a local-only placeholder through .env.local. Also remove
the unconditional NEXTAUTH_URL production-domain fallback, and only provide a
development fallback when explicitly non-production, using the existing
environment detection after it is initialized.
🪄 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: 320d55e5-129f-4b4e-abc6-0f3e441beba6

📥 Commits

Reviewing files that changed from the base of the PR and between 142c168 and c35a8ec.

📒 Files selected for processing (4)
  • src/beacon/components/device-model-3d-inner.tsx
  • src/beacon/components/device-model-3d.tsx
  • src/beacon/lib/auth.ts
  • src/beacon/public/hdri/potsdamer_platz_1k.hdr

Comment thread src/beacon/components/device-model-3d-inner.tsx
Comment thread src/beacon/lib/auth.ts Outdated
@github-actions

Copy link
Copy Markdown
Contributor

New azure beacon changes available for preview here

Copilot AI 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.

Pull request overview

This PR adjusts Beacon’s authentication configuration to handle missing NextAuth environment variables more gracefully, and refreshes the 3D device scene lighting by switching the HDRI environment source.

Changes:

  • Adds runtime fallbacks for NEXTAUTH_URL and NEXTAUTH_SECRET in Beacon’s NextAuth configuration.
  • Updates @react-three/drei <Environment /> to load a specific HDR file instead of using the "city" preset (in two 3D components).

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.

File Description
src/beacon/lib/auth.ts Introduces fallback behavior for NextAuth env vars used by Beacon authentication.
src/beacon/components/device-model-3d.tsx Switches the 3D environment lighting/background to a specific HDRI file.
src/beacon/components/device-model-3d-inner.tsx Mirrors the HDRI environment change for the inner 3D model component.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/beacon/lib/auth.ts Outdated
Comment thread src/beacon/lib/auth.ts Outdated
@OlukaGibson
OlukaGibson marked this pull request as draft July 10, 2026 11:29
@OlukaGibson
OlukaGibson marked this pull request as ready for review July 11, 2026 09:11
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown
Contributor

New azure beacon changes available for preview here

@OlukaGibson
OlukaGibson requested a review from Baalmart July 11, 2026 09:16

@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: 3

🤖 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 `@src/beacon/app/api/auth/`[...nextauth]/route.ts:
- Around line 4-24: Remove the request-header-based NEXTAUTH_URL mutation from
the handler and delete the associated getHeader, host, and proto logic. Use the
deployment-specific auth URL configuration from authOptions or the existing auth
setup in auth.ts, keeping the request flow request-scoped and leaving the
NextAuth(req, res, authOptions) invocation intact.

In `@src/beacon/lib/config.js`:
- Around line 20-29: Unify private-network detection used by getEnvironment()
and isLocalhost so environment, beaconApiPrefix, and requiresAuth share one
accurate check. Restrict the 172 range to 172.16–172.31, retain valid 10.x and
192.168.x private ranges, and reuse the shared helper in both paths instead of
maintaining separate hostname conditions.
- Around line 139-149: Update the configured URL handling in the
development/staging and production branches of the platform API resolver to
enforce HTTPS before returning remote URLs. Apply the same HTTPS normalization
or validation used by getBeaconApiUrl() to stagingUrl and prodUrl, while
preserving trailing-slash removal and the existing default staging URL behavior.
🪄 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: 08c212a2-8939-4d30-9912-23e5ddbcc824

📥 Commits

Reviewing files that changed from the base of the PR and between c35a8ec and 4e7faf8.

📒 Files selected for processing (3)
  • src/beacon/app/api/auth/[...nextauth]/route.ts
  • src/beacon/lib/auth.ts
  • src/beacon/lib/config.js

Comment thread src/beacon/app/api/auth/[...nextauth]/route.ts
Comment thread src/beacon/lib/config.js
Comment thread src/beacon/lib/config.js Outdated
@github-actions

Copy link
Copy Markdown
Contributor

New azure beacon changes available for preview here

@Baalmart
Baalmart merged commit 3b6f78c into staging Jul 11, 2026
24 checks passed
@Baalmart
Baalmart deleted the device-serial branch July 11, 2026 10:47
@Baalmart Baalmart mentioned this pull request Jul 11, 2026
2 tasks
@coderabbitai coderabbitai Bot mentioned this pull request Jul 13, 2026
7 tasks
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.

3 participants