Skip to content

Commit

Permalink
feat: updates related to new keycloak version (#86)
Browse files Browse the repository at this point in the history
* feat: updated env variable for keycloak

* feat: updated env variable for keycloak

* feat: updated KC_HOSTNAME to KC_HOSTNAME_URL
  • Loading branch information
Ani1357 authored Sep 28, 2023
1 parent b84539a commit ef7aff7
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ IDP_CLIENT_SECRET=''
IDP_GROUP_OTOMI_ADMIN='e69ded30-0882-4490-8e0f-2e67625a0693'
IDP_GROUP_TEAM_ADMIN='3c63814c-59df-46c3-9a69-d9e1c3611097'
IDP_GROUP_MAPPINGS_TEAMS='{"team-otomi":"28010af7-9535-4265-8689-50f51f8f2c87"}'
KEYCLOAK_ADDRESS='https://keycloak.dev.gke.otomi.cloud'
KC_HOSTNAME_URL='https://keycloak.dev.gke.otomi.cloud'
KEYCLOAK_ADMIN='admin'
KEYCLOAK_ADMIN_PASSWORD=''
KEYCLOAK_CLIENT_SECRET=''
Expand Down
10 changes: 5 additions & 5 deletions src/tasks/keycloak/keycloak.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
FEAT_EXTERNAL_IDP,
IDP_ALIAS,
IDP_OIDC_URL,
KEYCLOAK_ADDRESS,
KC_HOSTNAME_URL,
KEYCLOAK_ADDRESS_INTERNAL,
KEYCLOAK_ADMIN,
KEYCLOAK_ADMIN_PASSWORD,
Expand All @@ -53,7 +53,7 @@ const env = cleanEnv({
IDP_OIDC_URL,
KEYCLOAK_ADMIN,
KEYCLOAK_ADMIN_PASSWORD,
KEYCLOAK_ADDRESS,
KC_HOSTNAME_URL,
KEYCLOAK_ADDRESS_INTERNAL,
KEYCLOAK_REALM,
KEYCLOAK_TOKEN_TTL,
Expand All @@ -63,12 +63,12 @@ const env = cleanEnv({
const errors: string[] = []

async function main(): Promise<void> {
await waitTillAvailable(env.KEYCLOAK_ADDRESS)
const keycloakAddress = env.KEYCLOAK_ADDRESS
await waitTillAvailable(env.KC_HOSTNAME_URL)
const keycloakAddress = env.KC_HOSTNAME_URL
const basePath = `${keycloakAddress}/admin/realms`
let token: TokenSet
try {
custom.setHttpOptionsDefaults({ headers: { host: env.KEYCLOAK_ADDRESS.replace('https://', '') } })
custom.setHttpOptionsDefaults({ headers: { host: env.KC_HOSTNAME_URL.replace('https://', '') } })
const keycloakIssuer = await Issuer.discover(`${keycloakAddress}/realms/${env.KEYCLOAK_REALM}/`)
// console.log(keycloakIssuer)
const clientOptions: any = {
Expand Down
6 changes: 3 additions & 3 deletions src/tasks/keycloak/realm-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
IDP_OIDC_URL,
IDP_SUB_CLAIM_MAPPER,
IDP_USERNAME_CLAIM_MAPPER,
KEYCLOAK_ADDRESS,
KC_HOSTNAME_URL,
KEYCLOAK_CLIENT_SECRET,
KEYCLOAK_REALM,
REDIRECT_URIS,
Expand All @@ -49,7 +49,7 @@ const env = cleanEnv({
IDP_CLIENT_ID,
IDP_CLIENT_SECRET,
IDP_ALIAS,
KEYCLOAK_ADDRESS,
KC_HOSTNAME_URL,
KEYCLOAK_CLIENT_SECRET,
KEYCLOAK_REALM,
REDIRECT_URIS,
Expand All @@ -64,7 +64,7 @@ const env = cleanEnv({

export function createClient(): ClientRepresentation {
const redirectUris: Array<string> = env.REDIRECT_URIS
const webOrigins = [env.KEYCLOAK_ADDRESS]
const webOrigins = [env.KC_HOSTNAME_URL]
const secret = env.KEYCLOAK_CLIENT_SECRET
const otomiClientRepresentation = defaultsDeep(
new ClientRepresentation(),
Expand Down
2 changes: 1 addition & 1 deletion src/validators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const DRONE_TOKEN = str({ desc: 'The admin token to use for drone api ser
export const DRONE_URL = str({ desc: 'The public url of the drone server' })
export const GITEA_PASSWORD = str({ desc: 'The gitea admin password' })
export const GITEA_URL = url({ desc: 'The gitea core service url' })
export const KEYCLOAK_ADDRESS = str({ desc: 'The Keycloak Server address' })
export const KC_HOSTNAME_URL = str({ desc: 'The Keycloak Server address' })
export const KEYCLOAK_ADDRESS_INTERNAL = str({ desc: 'The internal Keycloak kubernetes svc address' })
export const KEYCLOAK_ADMIN = str({ desc: 'Default admin username for KeyCloak Server', default: 'admin' })
export const KEYCLOAK_ADMIN_PASSWORD = str({ desc: 'Default password for admin' })
Expand Down

0 comments on commit ef7aff7

Please sign in to comment.