Skip to content
Open
Changes from 1 commit
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
14 changes: 12 additions & 2 deletions src/common/api/Keycloak.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ let keycloak = null
let isInitialized = false
let initPromise = null

const keycloakConfig = {
"realm": "hmda2",
"url": "https://{{domain}}}/auth",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you try replacing line 9 with the following to make it dynamic?
"url": `https://${window.location.hostname}/auth`,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To account for local testing, please use the following:

let keycloakRedirect = null
if (hostname == 'localhost') {
  keycloakRedirect = 'ffiec.cfpb.gov'
} else {
  keycloakRedirect = hostname
}

const keycloakConfig = {
  "realm": "hmda2",
  "url": `https://${keycloakRedirect}/auth`,
  "clientId": "hmda2-api",
  "public-client": true,
  "use-resource-role-mappings": true,
  "confidential-port": 0,
  "ssl-required": "all"
}```

"clientId": "hmda2-api",
"public-client": true,
"use-resource-role-mappings": true,
"confidential-port": 0,
"ssl-required": "all"
}

export const setKeycloak = (cloak) => {
keycloak = cloak
return keycloak
Expand All @@ -28,12 +38,12 @@ export const initKeycloak = (overrides) => {
} else if (import.meta.env.MODE === 'development') {
keycloak = new Keycloak('/local_keycloak.json')
} else {
keycloak = new Keycloak('/keycloak.json')
keycloak = new Keycloak(keycloakConfig)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be any easier to manage/revert the keycloak config as a ConfigMap?

}
}

initPromise = keycloak
.init({ pkceMethod: 'S256' })
.init({ pkceMethod: 'S256', checkLoginIframe: false })
.then((authenticated) => {
console.log('Keycloak initialized, authenticated:', authenticated)
isInitialized = true
Expand Down