Skip to content

Conversation

JamieStivala
Copy link
Contributor

@JamieStivala JamieStivala commented Jul 23, 2025

💻 变更类型 | Change Type

  • ✨ feat
  • 🐛 fix
  • ♻️ refactor
  • 💄 style
  • 👷 build
  • ⚡️ perf
  • 📝 docs
  • 🔨 chore

🔀 变更说明 | Description of Change

Added support for Okta authentication

📝 补充信息 | Additional Information

Summary by Sourcery

Add support for Okta authentication by registering Okta environment variables for type declarations, validation, and configuration, emit deprecation warnings for them, update sign-in callback URL logic, and include tests for the new warnings.

New Features:

  • Include OKTA_CLIENT_ID, OKTA_CLIENT_SECRET, and OKTA_ISSUER in environment type declarations, validation schema, and config output
  • Emit deprecation warnings for Okta environment variables when they are set

Enhancements:

  • Change next-auth sign-in callbackUrl default fallback from '/' to an empty string

Tests:

  • Add unit test to verify deprecation warnings for Okta environment variables

Copy link

vercel bot commented Jul 23, 2025

@actions-user is attempting to deploy a commit to the LobeHub Community Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

sourcery-ai bot commented Jul 23, 2025

Reviewer's Guide

This PR introduces support for Okta authentication by extending environment configuration, deprecation warnings, and schema definitions, adds corresponding test coverage, and tweaks the default callback URL fallback in the sign-in component.

Class diagram for updated Auth environment configuration

classDiagram
    class Env {
        +ZITADEL_CLIENT_ID?: string
        +ZITADEL_CLIENT_SECRET?: string
        +ZITADEL_ISSUER?: string
        +OKTA_CLIENT_ID?: string
        +OKTA_CLIENT_SECRET?: string
        +OKTA_ISSUER?: string
        +LOGTO_CLIENT_ID?: string
        +LOGTO_CLIENT_SECRET?: string
        +LOGTO_ISSUER?: string
        ...
    }
Loading

Class diagram for getAuthConfig function changes

classDiagram
    class getAuthConfig {
        +createEnv()
        +add Okta env variables to schema
        +add Okta env variables to returned config
        +add Okta deprecation warnings
    }
Loading

File-Level Changes

Change Details Files
Extend auth configuration for Okta support
  • Add OKTA_CLIENT_ID, OKTA_CLIENT_SECRET, OKTA_ISSUER to global env types
  • Introduce console.warn calls for Okta deprecation templates
  • Include Okta vars in zod schema as optional fields
  • Populate Okta env values in the returned auth config
src/config/auth.ts
Cover Okta deprecation warnings in tests
  • Set Okta env vars in test fixture
  • Invoke getAuthConfig and spy on console.warn
  • Assert warnings match OKTA_CLIENT_ID/SECRET/ISSUER templates
src/config/__tests__/auth.test.ts
Modify default callback URL fallback
  • Change fallback value from '/' to empty string
  • Update inline comment to reflect new behavior
src/app/[variants]/(auth)/next-auth/signin/AuthSignInBox.tsx

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@lobehubbot
Copy link
Member

👍 @JamieStivala

Thank you for raising your pull request and contributing to our Community
Please make sure you have followed our contributing guidelines. We will review it as soon as possible.
If you encounter any problems, please feel free to connect with us.
非常感谢您提出拉取请求并为我们的社区做出贡献,请确保您已经遵循了我们的贡献指南,我们会尽快审查它。
如果您遇到任何问题,请随时与我们联系。

@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Jul 23, 2025
Copy link
Contributor

gru-agent bot commented Jul 23, 2025

TestGru Assignment

Summary

Link CommitId Status Reason
Detail 76ff1f6 🚫 Skipped No files need to be tested {"src/app/[variants]/(auth)/next-auth/signin/AuthSignInBox.tsx":"File path does not match include patterns.","src/config/tests/auth.test.ts":"File path does not match include patterns.","src/config/auth.ts":"File path does not match include patterns."}

History Assignment

Tip

You can @gru-agent and leave your feedback. TestGru will make adjustments based on your input

@dosubot dosubot bot added the 🌠 Feature Request New feature or request | 特性与建议 label Jul 23, 2025
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @JamieStivala - I've reviewed your changes and they look great!

Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments

### Comment 1
<location> `src/config/__tests__/auth.test.ts:199` </location>
<code_context>
       );
     });
   });
+  it('should warn about Okta deprecated environment variables', () => {
+    // Set all deprecated environment variables
+    process.env.OKTA_CLIENT_ID = 'okta_client_id';
+    process.env.OKTA_CLIENT_SECRET = 'okta_client_secret';
+    process.env.OKTA_ISSUER = 'okta_issuer';
+    // Call the function
+    getAuthConfig();
+
+    // Check that the spyConsoleWarn function was called for each deprecated environment variable
+    expect(spyConsoleWarn).toHaveBeenCalledWith(
+      expect.stringMatching(/OKTA_CLIENT_ID.*AUTH_OKTA_ID/),
+    );
</code_context>

<issue_to_address>
Missing test cleanup for environment variables.

Restore or unset the modified environment variables after the test to prevent side effects in other tests.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines 199 to 208
it('should warn about Okta deprecated environment variables', () => {
// Set all deprecated environment variables
process.env.OKTA_CLIENT_ID = 'okta_client_id';
process.env.OKTA_CLIENT_SECRET = 'okta_client_secret';
process.env.OKTA_ISSUER = 'okta_issuer';
// Call the function
getAuthConfig();

// Check that the spyConsoleWarn function was called for each deprecated environment variable
expect(spyConsoleWarn).toHaveBeenCalledWith(
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion (testing): Missing test cleanup for environment variables.

Restore or unset the modified environment variables after the test to prevent side effects in other tests.

Copy link
Member

@arvinxx arvinxx left a comment

Choose a reason for hiding this comment

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

the implement is not correctly , please check other pr like #7342. And add relative documents

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Jul 24, 2025
@JamieStivala JamieStivala changed the title Add support for Okta Authentication ✨ feat: Add support for Okta Authentication Jul 24, 2025
Copy link

codecov bot commented Jul 24, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.58%. Comparing base (fdaa725) to head (1b1fb1e).
⚠️ Report is 26 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #8547   +/-   ##
=======================================
  Coverage   85.58%   85.58%           
=======================================
  Files         910      910           
  Lines       69093    69093           
  Branches     4530     4531    +1     
=======================================
  Hits        59134    59134           
  Misses       9959     9959           
Flag Coverage Δ
app 85.58% <ø> (ø)
server 96.26% <ø> (ø)

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.

@JamieStivala
Copy link
Contributor Author

Thank you for your reply. I just implemented the changes as per PR #7342, and removed any references to the old "runtimeEnv" Environment Variables (as well as the tests). Please let me know if there are any further changes I need to make.

Unfortunately, I am not able to translate the documentation from English to Chinese, as I do not possess the language knowledge.

Additionally, sorry for the commit spam. I forgot to include some files in the original commits. Should be all good now.

Copy link
Member

@arvinxx arvinxx left a comment

Choose a reason for hiding this comment

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

LGTM. I will add Chinese docs for you. Thanks for your contribution!

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jul 29, 2025
Copy link

vercel bot commented Jul 29, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
lobe-chat-database ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 29, 2025 0:48am

@arvinxx arvinxx merged commit 67abdfe into lobehub:main Jul 29, 2025
27 of 28 checks passed
@lobehubbot
Copy link
Member

❤️ Great PR @JamieStivala ❤️

The growth of project is inseparable from user feedback and contribution, thanks for your contribution! If you are interesting with the lobehub developer community, please join our discord and then dm @arvinxx or @canisminor1990. They will invite you to our private developer channel. We are talking about the lobe-chat development or sharing ai newsletter around the world.
项目的成长离不开用户反馈和贡献,感谢您的贡献! 如果您对 LobeHub 开发者社区感兴趣,请加入我们的 discord,然后私信 @arvinxx@canisminor1990。他们会邀请您加入我们的私密开发者频道。我们将会讨论关于 Lobe Chat 的开发,分享和讨论全球范围内的 AI 消息。

github-actions bot pushed a commit that referenced this pull request Jul 29, 2025
## [Version&nbsp;1.106.0](v1.105.6...v1.106.0)
<sup>Released on **2025-07-29**</sup>

#### ✨ Features

- **misc**: Add support for Okta Authentication.

<br/>

<details>
<summary><kbd>Improvements and Fixes</kbd></summary>

#### What's improved

* **misc**: Add support for Okta Authentication, closes [#8547](#8547) ([67abdfe](67abdfe))

</details>

<div align="right">

[![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)

</div>
@lobehubbot
Copy link
Member

🎉 This PR is included in version 1.106.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

github-actions bot pushed a commit to jaworldwideorg/OneJA-Bot that referenced this pull request Jul 29, 2025
## [Version&nbsp;1.105.0](v1.104.1...v1.105.0)
<sup>Released on **2025-07-29**</sup>

#### ✨ Features

- **misc**: Add support for Okta Authentication.

#### 🐛 Bug Fixes

- **misc**: Fix subscription plan tag display, reorder AppTheme and Locale to fix modal i18n, revert jose to ^5 to fix auth issue on desktop.

#### 💄 Styles

- **misc**: Open new topic by tap Just Chat again, support Minimax T2I models.

<br/>

<details>
<summary><kbd>Improvements and Fixes</kbd></summary>

#### What's improved

* **misc**: Add support for Okta Authentication, closes [lobehub#8547](https://github.com/jaworldwideorg/OneJA-Bot/issues/8547) ([67abdfe](67abdfe))

#### What's fixed

* **misc**: Fix subscription plan tag display, closes [lobehub#8599](https://github.com/jaworldwideorg/OneJA-Bot/issues/8599) ([2a3754a](2a3754a))
* **misc**: Reorder AppTheme and Locale to fix modal i18n, closes [lobehub#8600](https://github.com/jaworldwideorg/OneJA-Bot/issues/8600) ([3264cf2](3264cf2))
* **misc**: Revert jose to ^5 to fix auth issue on desktop, closes [lobehub#8603](https://github.com/jaworldwideorg/OneJA-Bot/issues/8603) ([57118b0](57118b0))

#### Styles

* **misc**: Open new topic by tap Just Chat again, closes [lobehub#8426](https://github.com/jaworldwideorg/OneJA-Bot/issues/8426) ([018ca75](018ca75))
* **misc**: Support Minimax T2I models, closes [lobehub#8583](https://github.com/jaworldwideorg/OneJA-Bot/issues/8583) ([f8a01aa](f8a01aa))

</details>

<div align="right">

[![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)

</div>
bbbugg pushed a commit to bbbugg/lobe-chat that referenced this pull request Aug 14, 2025
* Add Okta support to auth config and tests

* Added documentation

* Removed deprecated env variables

* Added Okta as SSO Provider

* Removed Okta Test

* Reverted a micro-change which was changed during some testing (back to original)

* Added Okta to SSO providers list
bbbugg pushed a commit to bbbugg/lobe-chat that referenced this pull request Aug 14, 2025
## [Version&nbsp;1.106.0](lobehub/lobe-chat@v1.105.6...v1.106.0)
<sup>Released on **2025-07-29**</sup>

#### ✨ Features

- **misc**: Add support for Okta Authentication.

<br/>

<details>
<summary><kbd>Improvements and Fixes</kbd></summary>

#### What's improved

* **misc**: Add support for Okta Authentication, closes [lobehub#8547](lobehub#8547) ([ad57abe](lobehub@ad57abe))

</details>

<div align="right">

[![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)

</div>
cy948 pushed a commit to cy948/lobe-chat that referenced this pull request Aug 23, 2025
* Add Okta support to auth config and tests

* Added documentation

* Removed deprecated env variables

* Added Okta as SSO Provider

* Removed Okta Test

* Reverted a micro-change which was changed during some testing (back to original)

* Added Okta to SSO providers list
cy948 pushed a commit to cy948/lobe-chat that referenced this pull request Aug 23, 2025
## [Version&nbsp;1.106.0](lobehub/lobe-chat@v1.105.6...v1.106.0)
<sup>Released on **2025-07-29**</sup>

#### ✨ Features

- **misc**: Add support for Okta Authentication.

<br/>

<details>
<summary><kbd>Improvements and Fixes</kbd></summary>

#### What's improved

* **misc**: Add support for Okta Authentication, closes [lobehub#8547](lobehub#8547) ([67abdfe](lobehub@67abdfe))

</details>

<div align="right">

[![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)

</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🌠 Feature Request New feature or request | 特性与建议 lgtm This PR has been approved by a maintainer released size:L This PR changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants