[PR #6057] [MERGED] fix: genericOAuth and SSO ignore discoveryUrl for authorization #14659

Closed
opened 2026-04-13 09:34:08 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/6057
Author: @GautamBytes
Created: 11/18/2025
Status: Merged
Merged: 11/18/2025
Merged by: @Bekacru

Base: canaryHead: fix/discovery-url-lookup


📝 Commits (1)

  • c89873e fix: genericOAuth and SSO ignore discoveryUrl for authorization

📊 Changes

2 files changed (+39 additions, -3 deletions)

View changed files

📝 packages/better-auth/src/plugins/generic-oauth/index.ts (+22 -2)
📝 packages/sso/src/routes/sso.ts (+17 -1)

📄 Description

Description

This PR fixes an issue where generic-oauth and SSO providers would crash with a TypeError: Invalid URL if only a discoveryUrl was provided without an explicit authorizationUrl.

Changes

  • generic-oauth: Updated createAuthorizationURL to fetch the authorization_endpoint from the discoveryUrl if it is not explicitly defined.
  • SSO: Updated signInSSO to perform the same discovery lookup, resolving the issue reported in the comments by @aheidelberg here.

Fixes #6042


Summary by cubic

Fixes a crash where generic OAuth and SSO failed with “TypeError: Invalid URL” when only a discoveryUrl was configured. Both flows now resolve the authorization endpoint via OIDC discovery and validate the config.

  • Bug Fixes
    • generic-oauth: createAuthorizationURL fetches authorization_endpoint (and userinfo_endpoint) from discoveryUrl when authorizationUrl is missing, and throws a clear error if not found.
    • SSO: signInSSO looks up authorization_endpoint from discoveryEndpoint when absent and validates before building the redirect URL.

Written for commit c89873e546. Summary will update automatically on new commits.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/6057 **Author:** [@GautamBytes](https://github.com/GautamBytes) **Created:** 11/18/2025 **Status:** ✅ Merged **Merged:** 11/18/2025 **Merged by:** [@Bekacru](https://github.com/Bekacru) **Base:** `canary` ← **Head:** `fix/discovery-url-lookup` --- ### 📝 Commits (1) - [`c89873e`](https://github.com/better-auth/better-auth/commit/c89873e546f2e34e9b4c2e35410df83f3afc84ac) fix: genericOAuth and SSO ignore discoveryUrl for authorization ### 📊 Changes **2 files changed** (+39 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/plugins/generic-oauth/index.ts` (+22 -2) 📝 `packages/sso/src/routes/sso.ts` (+17 -1) </details> ### 📄 Description ## Description This PR fixes an issue where `generic-oauth` and `SSO` providers would crash with a `TypeError: Invalid URL` if only a `discoveryUrl` was provided without an explicit `authorizationUrl`. ## Changes - **generic-oauth:** Updated `createAuthorizationURL` to fetch the `authorization_endpoint` from the `discoveryUrl` if it is not explicitly defined. - **SSO:** Updated `signInSSO` to perform the same discovery lookup, resolving the issue reported in the comments by @aheidelberg [here](https://github.com/better-auth/better-auth/issues/6042#issuecomment-3543396443). ## Related Issue Fixes #6042 <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Fixes a crash where generic OAuth and SSO failed with “TypeError: Invalid URL” when only a discoveryUrl was configured. Both flows now resolve the authorization endpoint via OIDC discovery and validate the config. - **Bug Fixes** - generic-oauth: createAuthorizationURL fetches authorization_endpoint (and userinfo_endpoint) from discoveryUrl when authorizationUrl is missing, and throws a clear error if not found. - SSO: signInSSO looks up authorization_endpoint from discoveryEndpoint when absent and validates before building the redirect URL. <sup>Written for commit c89873e546f2e34e9b4c2e35410df83f3afc84ac. Summary will update automatically on new commits.</sup> <!-- End of auto-generated description by cubic. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-13 09:34:08 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#14659