Skip to content

Commit 2be0b85

Browse files
dependabot[bot]Ani1357svcAPLBotCasLubbersElderMatt
authored
chore(deps): Bump openid-client from 5.7.0 to 6.6.2 (#270)
* chore(release): 3.14.0 (#272) * chore: release branch [ci skip] * chore(release): 3.14.0 * chore(deps): Bump openid-client from 5.7.0 to 6.6.2 Bumps [openid-client](https://github.com/panva/openid-client) from 5.7.0 to 6.6.2. - [Release notes](https://github.com/panva/openid-client/releases) - [Changelog](https://github.com/panva/openid-client/blob/main/CHANGELOG.md) - [Commits](panva/openid-client@v5.7.0...v6.6.2) --- updated-dependencies: - dependency-name: openid-client dependency-version: 6.6.2 dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> * fix: update Keycloak connection to use new openid-client methods * fix: update Keycloak connection to use new openid-client methods * fix: correct issuer URL format in Keycloak token request * fix: update Keycloak token request to use direct fetch instead of openid-client methods * fix: package-lock --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: Ani Argjiri <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: svcAPLBot <[email protected]> Co-authored-by: Cas Lubbers <[email protected]> Co-authored-by: ElderMatt <[email protected]>
1 parent d17a6c5 commit 2be0b85

File tree

3 files changed

+36
-100
lines changed

3 files changed

+36
-100
lines changed

package-lock.json

Lines changed: 11 additions & 85 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"generate-password": "^1.7.1",
2424
"js-yaml": "4.1.0",
2525
"lodash": "4.17.21",
26-
"openid-client": "5.7.0",
26+
"openid-client": "6.6.2",
2727
"tsx": "^4.20.5"
2828
},
2929
"description": "Tasks needed by the APL Container Platform to glue all the pieces together.",

src/operators/keycloak/keycloak.ts

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
UsersApi,
1919
} from '@linode/keycloak-client-node'
2020
import { forEach, omit } from 'lodash'
21-
import { custom, Issuer, TokenSet } from 'openid-client'
21+
import { type TokenEndpointResponse } from 'openid-client'
2222
import { keycloakRealm } from '../../tasks/keycloak/config'
2323
import { extractError } from '../../tasks/keycloak/errors'
2424
import {
@@ -51,7 +51,7 @@ import {
5151

5252
interface KeycloakConnection {
5353
basePath: string
54-
token: TokenSet
54+
token: TokenEndpointResponse
5555
}
5656

5757
interface KeycloakApi {
@@ -335,20 +335,30 @@ async function keycloakConfigMapChanges(api: KeycloakApi) {
335335

336336
async function createKeycloakConnection(): Promise<KeycloakConnection> {
337337
const basePath = env.KEYCLOAK_HOSTNAME_URL
338-
let token: TokenSet
338+
let token: TokenEndpointResponse
339339
try {
340-
custom.setHttpOptionsDefaults({ headers: { host: env.KEYCLOAK_HOSTNAME_URL.replace('https://', '') } })
341-
const keycloakIssuer = await Issuer.discover(`${basePath}/realms/${env.KEYCLOAK_REALM}/`)
342-
const clientOptions: any = {
343-
client_id: 'admin-cli',
344-
client_secret: 'unused',
345-
}
346-
const openIdConnectClient = new keycloakIssuer.Client(clientOptions)
347-
token = await openIdConnectClient.grant({
348-
grant_type: 'password',
349-
username: env.KEYCLOAK_ADMIN,
350-
password: env.KEYCLOAK_ADMIN_PASSWORD,
340+
// Use master realm for admin authentication
341+
const tokenUrl = `${basePath}/realms/master/protocol/openid-connect/token`
342+
343+
const response = await fetch(tokenUrl, {
344+
method: 'POST',
345+
headers: {
346+
'Content-Type': 'application/x-www-form-urlencoded',
347+
},
348+
body: new URLSearchParams({
349+
grant_type: 'password',
350+
client_id: 'admin-cli',
351+
username: env.KEYCLOAK_ADMIN,
352+
password: env.KEYCLOAK_ADMIN_PASSWORD,
353+
}),
351354
})
355+
356+
if (!response.ok) {
357+
throw new Error(`Token request failed: ${response.status} ${response.statusText}`)
358+
}
359+
360+
token = await response.json() as TokenEndpointResponse
361+
352362
return { token, basePath } as KeycloakConnection
353363
} catch (error) {
354364
throw extractError('creating Keycloak connection', error)

0 commit comments

Comments
 (0)