Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/every-pugs-wave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@hono/oidc-auth': minor
---

Support empty OIDC_CLIENT_SECRET
17 changes: 12 additions & 5 deletions packages/oidc-auth/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
if (!oidcAuthEnv.OIDC_REDIRECT_URI.startsWith('/')) {
try {
new URL(oidcAuthEnv.OIDC_REDIRECT_URI)
} catch (e) {

Check warning on line 120 in packages/oidc-auth/src/index.ts

View workflow job for this annotation

GitHub Actions / ci

'e' is defined but never used
throw new HTTPException(500, {
message: 'The OIDC redirect URI is invalid. It must be a full URL or an absolute path',
})
Expand Down Expand Up @@ -167,11 +167,18 @@
const env = getOidcAuthEnv(c)
let client = c.get('oidcClient')
if (client === undefined) {
client = {
client_id: env.OIDC_CLIENT_ID,
client_secret: env.OIDC_CLIENT_SECRET,
token_endpoint_auth_method: 'client_secret_basic',
}
client =
env.OIDC_CLIENT_SECRET === ''
? {
// No client secret provided, use 'none' auth method
client_id: env.OIDC_CLIENT_ID,
token_endpoint_auth_method: 'none',
}
: {
client_id: env.OIDC_CLIENT_ID,
client_secret: env.OIDC_CLIENT_SECRET,
token_endpoint_auth_method: 'client_secret_basic',
}
c.set('oidcClient', client)
}
return client
Expand All @@ -191,7 +198,7 @@
}
try {
auth = (await verify(session_jwt, env.OIDC_AUTH_SECRET)) as OidcAuth
} catch (e) {

Check warning on line 201 in packages/oidc-auth/src/index.ts

View workflow job for this annotation

GitHub Actions / ci

'e' is defined but never used
deleteCookie(c, env.OIDC_COOKIE_NAME, { path: env.OIDC_COOKIE_PATH })
return null
}
Expand Down Expand Up @@ -463,7 +470,7 @@
setCookie(c, 'continue', c.req.url, cookieOptions)
return c.redirect(url)
}
} catch (e) {

Check warning on line 473 in packages/oidc-auth/src/index.ts

View workflow job for this annotation

GitHub Actions / ci

'e' is defined but never used
deleteCookie(c, env.OIDC_COOKIE_NAME, { path: env.OIDC_COOKIE_PATH })
throw new HTTPException(500, { message: 'Invalid session' })
}
Expand Down