Skip to content

Commit 7eee61b

Browse files
committed
feat(oidc-auth): support empty OIDC client secret
1 parent 6c36f52 commit 7eee61b

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

.changeset/every-pugs-wave.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@hono/oidc-auth': major
3+
---
4+
5+
Support empty OIDC_CLIENT_SECRET

packages/oidc-auth/src/index.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,18 @@ export const getClient = (c: Context): oauth2.Client => {
167167
const env = getOidcAuthEnv(c)
168168
let client = c.get('oidcClient')
169169
if (client === undefined) {
170-
client = {
171-
client_id: env.OIDC_CLIENT_ID,
172-
client_secret: env.OIDC_CLIENT_SECRET,
173-
token_endpoint_auth_method: 'client_secret_basic',
174-
}
170+
client =
171+
env.OIDC_CLIENT_SECRET === ''
172+
? {
173+
// No client secret provided, use 'none' auth method
174+
client_id: env.OIDC_CLIENT_ID,
175+
token_endpoint_auth_method: 'none',
176+
}
177+
: {
178+
client_id: env.OIDC_CLIENT_ID,
179+
client_secret: env.OIDC_CLIENT_SECRET,
180+
token_endpoint_auth_method: 'client_secret_basic',
181+
}
175182
c.set('oidcClient', client)
176183
}
177184
return client

0 commit comments

Comments
 (0)