[PR #2326] [CLOSED] fix(oidc-provider): Update advertised ID token signing alg to HS256 #4262

Closed
opened 2026-03-13 11:39:46 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/2326
Author: @benoitcanton
Created: 4/16/2025
Status: Closed

Base: mainHead: fix-oidc-signing-alg


📝 Commits (1)

  • d77770f Update advertised ID token signing alg to HS256

📊 Changes

2 files changed (+4 additions, -4 deletions)

View changed files

📝 packages/better-auth/src/plugins/oidc-provider/index.ts (+1 -1)
📝 packages/better-auth/src/plugins/oidc-provider/types.ts (+3 -3)

📄 Description

The current generated key used to sign the ID token, is using HS256 algorithm while the openid-configuration endpoint is advertising RS256 as the only signing algorithm.

Line 598:

let secretKey = {
        alg: "HS256",
        key: await subtle.generateKey(
	        {
		        name: "HMAC",
		        hash: "SHA-256",
	        },
	        true,
	        ["sign", "verify"],
        ),
};

A current ID token decoded header looks like

{
  "alg": "HS256"
}

Where the openid-configuration returns

{
  "issuer": "http://localhost:3002",
  "authorization_endpoint": "http://localhost:3002/api/auth/oauth2/authorize",
  "token_endpoint": "http://localhost:3002/api/auth/oauth2/token",
  "userinfo_endpoint": "http://localhost:3002/api/auth/oauth2/userinfo",
  "jwks_uri": "http://localhost:3002/api/auth/jwks",
  "registration_endpoint": "http://localhost:3002/api/auth/oauth2/register",
  ...
  "id_token_signing_alg_values_supported": [
    "RS256",
    "none"
  ],
 ...
}

While it doesn't address the fact that the key used is not one of the keys advertised in the JWKS endpoint (probably due to the fact that they are not from the same plugin?)-At least, now, the alg property of the ID token header is matching the openid-configuration.


🔄 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/2326 **Author:** [@benoitcanton](https://github.com/benoitcanton) **Created:** 4/16/2025 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix-oidc-signing-alg` --- ### 📝 Commits (1) - [`d77770f`](https://github.com/better-auth/better-auth/commit/d77770fccda8a01d90304f0a7793c954329a5ff8) Update advertised ID token signing alg to HS256 ### 📊 Changes **2 files changed** (+4 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/plugins/oidc-provider/index.ts` (+1 -1) 📝 `packages/better-auth/src/plugins/oidc-provider/types.ts` (+3 -3) </details> ### 📄 Description The current generated key used to sign the ID token, is using `HS256` algorithm while the openid-configuration endpoint is advertising `RS256` as the only signing algorithm. Line 598: ``` let secretKey = { alg: "HS256", key: await subtle.generateKey( { name: "HMAC", hash: "SHA-256", }, true, ["sign", "verify"], ), }; ``` A current ID token decoded header looks like ``` { "alg": "HS256" } ``` Where the openid-configuration returns ``` { "issuer": "http://localhost:3002", "authorization_endpoint": "http://localhost:3002/api/auth/oauth2/authorize", "token_endpoint": "http://localhost:3002/api/auth/oauth2/token", "userinfo_endpoint": "http://localhost:3002/api/auth/oauth2/userinfo", "jwks_uri": "http://localhost:3002/api/auth/jwks", "registration_endpoint": "http://localhost:3002/api/auth/oauth2/register", ... "id_token_signing_alg_values_supported": [ "RS256", "none" ], ... } ``` While it doesn't address the fact that the key used is not one of the keys advertised in the JWKS endpoint (probably due to the fact that they are not from the same plugin?)-At least, now, the `alg` property of the ID token header is matching the openid-configuration. --- <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-03-13 11:39:46 -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#4262