[GH-ISSUE #8426] Support RFC 8252 loopback support for oauthProvider plugin #28412

Open
opened 2026-04-17 19:52:12 -05:00 by GiteaMirror · 0 comments
Owner

Originally created by @shadiramadan on GitHub (Mar 5, 2026).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/8426

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

Setup oauthProvider
Create a public oauth client.

async function seed() {
  await db
    .insert(oauthClients)
    .values({
      clientId: "example",
      name: "Example",
      // RFC 8252 §7.3: Loopback redirects should match host+path, allowing any port.
      // Native apps bind to ephemeral ports at runtime.
      redirectUris: ["http://127.0.0.1/callback"],
      tokenEndpointAuthMethod: "none",
      grantTypes: ["authorization_code", "refresh_token"],
      public: true,
      skipConsent: true,
      enableEndSession: true,
      createdAt: new Date(),
      updatedAt: new Date(),
      scopes: ["openid", "profile", "email", "offline_access"],
    })
    .onConflictDoNothing({ target: oauthClients.clientId });
}

Current vs. Expected behavior

Redirect URI validation uses strict string matching.
Native CLI apps must hardcode a fixed port, risking port conflicts if that port is already in use.

Per RFC 8252 7.3

The authorization server MUST allow any port to be specified at the time of the request for loopback IP redirect URIs, to accommodate clients that obtain an available ephemeral port from the operating system at the time of the request.

A registered loopback URI not specifying port should match any port.

What version of Better Auth are you using?

1.4.19

System info

N/A

Which area(s) are affected? (Select all that apply)

Backend

Auth config (if applicable)


Additional context

No response

Originally created by @shadiramadan on GitHub (Mar 5, 2026). Original GitHub issue: https://github.com/better-auth/better-auth/issues/8426 ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce Setup oauthProvider Create a public oauth client. ```ts async function seed() { await db .insert(oauthClients) .values({ clientId: "example", name: "Example", // RFC 8252 §7.3: Loopback redirects should match host+path, allowing any port. // Native apps bind to ephemeral ports at runtime. redirectUris: ["http://127.0.0.1/callback"], tokenEndpointAuthMethod: "none", grantTypes: ["authorization_code", "refresh_token"], public: true, skipConsent: true, enableEndSession: true, createdAt: new Date(), updatedAt: new Date(), scopes: ["openid", "profile", "email", "offline_access"], }) .onConflictDoNothing({ target: oauthClients.clientId }); } ``` ### Current vs. Expected behavior Redirect URI validation uses strict string matching. Native CLI apps must hardcode a fixed port, risking port conflicts if that port is already in use. Per [RFC 8252 7.3](https://www.rfc-editor.org/rfc/rfc8252.html#section-7.3) >The authorization server MUST allow any port to be specified at the time of the request for loopback IP redirect URIs, to accommodate clients that obtain an available ephemeral port from the operating system at the time of the request. A registered loopback URI not specifying port should match any port. ### What version of Better Auth are you using? 1.4.19 ### System info ```bash N/A ``` ### Which area(s) are affected? (Select all that apply) Backend ### Auth config (if applicable) ```typescript ``` ### Additional context _No response_
GiteaMirror added the identity label 2026-04-17 19:52:12 -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#28412