Skip to content

Commit

Permalink
TechDebt: Port Missing Pipeline Keycloak Changes From SIMS
Browse files Browse the repository at this point in the history
Continuation of #219.

Ported over auth/keycloak changes from SIMS but missed some changes that impacted the pipeline (wouldn't be noticed when running locally).
  • Loading branch information
NickPhura authored Jan 4, 2024
2 parents 0f6ba8b + b781b77 commit 8fe0002
Show file tree
Hide file tree
Showing 11 changed files with 256 additions and 181 deletions.
66 changes: 42 additions & 24 deletions .config/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,37 +41,55 @@
},
"sso": {
"dev": {
"url": "https://dev.loginproxy.gov.bc.ca/auth",
"clientId": "bio-hub-browser-4230",
"host": "https://dev.loginproxy.gov.bc.ca/auth",
"realm": "standard",
"integrationId": "4230",
"adminHost": "https://loginproxy.gov.bc.ca/auth",
"adminUserName": "biohub-svc-4466",
"apiHost": "https://api.loginproxy.gov.bc.ca/api/v1",
"keycloakSecret": "keycloak-admin-password",
"keycloakSecretAdminPassword": "keycloak_admin_password"
"clientId": "bio-hub-browser-4230",
"keycloakSecret": "keycloak",
"serviceClient": {
"serviceClientName": "biohub-svc-4466",
"keycloakSecretServiceClientPasswordKey": "biohub_svc_client_password"
},
"cssApi": {
"cssApiTokenUrl": "https://loginproxy.gov.bc.ca/auth/realms/standard/protocol/openid-connect/token",
"cssApiClientId": "service-account-team-1159-4197",
"cssApiHost": "https://api.loginproxy.gov.bc.ca/api/v1",
"keycloakSecretCssApiSecretKey": "css_api_client_secret",
"cssApiEnvironment": "dev"
}
},
"test": {
"url": "https://test.loginproxy.gov.bc.ca/auth",
"clientId": "bio-hub-browser-4230",
"host": "https://test.loginproxy.gov.bc.ca/auth",
"realm": "standard",
"integrationId": "4230",
"adminHost": "https://loginproxy.gov.bc.ca/auth",
"adminUserName": "biohub-svc-4466",
"apiHost": "https://api.loginproxy.gov.bc.ca/api/v1",
"keycloakSecret": "keycloak-admin-password",
"keycloakSecretAdminPassword": "keycloak_admin_password"
"clientId": "bio-hub-browser-4230",
"keycloakSecret": "keycloak",
"serviceClient": {
"serviceClientName": "biohub-svc-4466",
"keycloakSecretServiceClientPasswordKey": "biohub_svc_client_password"
},
"cssApi": {
"cssApiTokenUrl": "https://loginproxy.gov.bc.ca/auth/realms/standard/protocol/openid-connect/token",
"cssApiClientId": "service-account-team-1159-4197",
"cssApiHost": "https://api.loginproxy.gov.bc.ca/api/v1",
"keycloakSecretCssApiSecretKey": "css_api_client_secret",
"cssApiEnvironment": "test"
}
},
"prod": {
"url": "https://loginproxy.gov.bc.ca/auth",
"clientId": "bio-hub-browser-4230",
"host": "https://loginproxy.gov.bc.ca/auth",
"realm": "standard",
"integrationId": "4230",
"adminHost": "https://loginproxy.gov.bc.ca/auth",
"adminUserName": "biohub-svc-4466",
"apiHost": "https://api.loginproxy.gov.bc.ca/api/v1",
"keycloakSecret": "keycloak-admin-password",
"keycloakSecretAdminPassword": "keycloak_admin_password"
"clientId": "bio-hub-browser-4230",
"keycloakSecret": "keycloak",
"serviceClient": {
"serviceClientName": "biohub-svc-4466",
"keycloakSecretServiceClientPasswordKey": "biohub_svc_client_password"
},
"cssApi": {
"cssApiTokenUrl": "https://loginproxy.gov.bc.ca/auth/realms/standard/protocol/openid-connect/token",
"cssApiClientId": "service-account-team-1159-4197",
"cssApiHost": "https://api.loginproxy.gov.bc.ca/api/v1",
"keycloakSecretCssApiSecretKey": "css_api_client_secret",
"cssApiEnvironment": "prod"
}
}
}
}
20 changes: 13 additions & 7 deletions api/.pipeline/lib/api.deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,20 @@ const apiDeploy = async (settings) => {
TZ: phases[phase].tz,
DB_SERVICE_NAME: `${phases[phase].dbName}-postgresql${phases[phase].suffix}`,
// Keycloak
KEYCLOAK_ADMIN_USERNAME: phases[phase].sso.adminUserName,
KEYCLOAK_SECRET: phases[phase].sso.keycloakSecret,
KEYCLOAK_SECRET_ADMIN_PASSWORD: phases[phase].sso.keycloakSecretAdminPassword,
KEYCLOAK_HOST: phases[phase].sso.url,
KEYCLOAK_CLIENT_ID: phases[phase].sso.clientId,
KEYCLOAK_HOST: phases[phase].sso.host,
KEYCLOAK_REALM: phases[phase].sso.realm,
KEYCLOAK_INTEGRATION_ID: phases[phase].sso.integrationId,
KEYCLOAK_API_HOST: phases[phase].sso.apiHost,
KEYCLOAK_CLIENT_ID: phases[phase].sso.clientId,
// Keycloak secret
KEYCLOAK_SECRET: phases[phase].sso.keycloakSecret,
// Keycloak Service Client
KEYCLOAK_ADMIN_USERNAME: phases[phase].sso.serviceClient.serviceClientName,
KEYCLOAK_SECRET_ADMIN_PASSWORD_KEY: phases[phase].sso.serviceClient.keycloakSecretServiceClientPasswordKey,
// Keycloak CSS API
KEYCLOAK_API_TOKEN_URL: phases[phase].sso.cssApi.cssApiTokenUrl,
KEYCLOAK_API_CLIENT_ID: phases[phase].sso.cssApi.cssApiClientId,
KEYCLOAK_API_CLIENT_SECRET_KEY: phases[phase].sso.cssApi.keycloakSecretCssApiSecretKey,
KEYCLOAK_API_HOST: phases[phase].sso.cssApi.cssApiHost,
KEYCLOAK_API_ENVIRONMENT: phases[phase].sso.cssApi.cssApiEnvironment,
// Log Level
LOG_LEVEL: phases[phase].logLevel || 'info',
// OPenshift Resources
Expand Down
56 changes: 41 additions & 15 deletions api/.pipeline/templates/api.dc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,35 +56,49 @@ parameters:
description: Application timezone
required: false
value: 'America/Vancouver'
# Keycloak
- name: KEYCLOAK_HOST
description: Key clock login url
required: true
- name: KEYCLOAK_REALM
description: Realm identifier or name
required: true
- name: KEYCLOAK_INTEGRATION_ID
description: keycloak integration id
required: true
- name: KEYCLOAK_API_HOST
description: keycloak API host
required: true
- name: KEYCLOAK_CLIENT_ID
description: Client Id for application
required: true
- name: KEYCLOAK_ADMIN_USERNAME
description: keycloak host admin username
required: true
# Keycloak secret
- name: KEYCLOAK_SECRET
description: The name of the keycloak secret
required: true
- name: KEYCLOAK_SECRET_ADMIN_PASSWORD
# Keycloak Service Client
- name: KEYCLOAK_ADMIN_USERNAME
description: keycloak host admin username
required: true
- name: KEYCLOAK_SECRET_ADMIN_PASSWORD_KEY
description: The key of the admin password in the keycloak secret
required: true
# Keycloak CSS API
- name: KEYCLOAK_API_TOKEN_URL
description: The url to fetch a css api access token, which is needed to call the css rest api
required: true
- name: KEYCLOAK_API_CLIENT_ID
description: The css api client id
required: true
- name: KEYCLOAK_API_CLIENT_SECRET_KEY
description: The css api client secret
required: true
- name: KEYCLOAK_API_HOST
description: The url of the css rest api
required: true
- name: KEYCLOAK_API_ENVIRONMENT
description: The css api environment to query (dev, test, prod)
required: true
- name: API_PORT_DEFAULT
value: '6100'
- name: API_PORT_DEFAULT_NAME
description: Api default port name
value: '6100-tcp'
# Object Store (S3)
- name: OBJECT_STORE_SECRETS
description: Secrets used to read and write to the S3 storage
value: 'biohubbc-object-store'
Expand Down Expand Up @@ -203,23 +217,35 @@ objects:
name: ${DB_SERVICE_NAME}
- name: DB_PORT
value: '5432'
# Keycloak
- name: KEYCLOAK_HOST
value: ${KEYCLOAK_HOST}
- name: KEYCLOAK_API_HOST
value: ${KEYCLOAK_API_HOST}
- name: KEYCLOAK_REALM
value: ${KEYCLOAK_REALM}
- name: KEYCLOAK_CLIENT_ID
value: ${KEYCLOAK_CLIENT_ID}
- name: KEYCLOAK_INTEGRATION_ID
value: ${KEYCLOAK_INTEGRATION_ID}
# Keycloak Service Client
- name: KEYCLOAK_ADMIN_USERNAME
value: ${KEYCLOAK_ADMIN_USERNAME}
- name: KEYCLOAK_ADMIN_PASSWORD
valueFrom:
secretKeyRef:
name: ${KEYCLOAK_SECRET}
key: ${KEYCLOAK_SECRET_ADMIN_PASSWORD}
key: ${KEYCLOAK_SECRET_ADMIN_PASSWORD_KEY}
# Keycloak CSS API
- name: KEYCLOAK_API_TOKEN_URL
value: ${KEYCLOAK_API_TOKEN_URL}
- name: KEYCLOAK_API_CLIENT_ID
value: ${KEYCLOAK_API_CLIENT_ID}
- name: KEYCLOAK_API_CLIENT_SECRET
valueFrom:
secretKeyRef:
name: ${KEYCLOAK_SECRET}
key: ${KEYCLOAK_API_CLIENT_SECRET_KEY}
- name: KEYCLOAK_API_HOST
value: ${KEYCLOAK_API_HOST}
- name: KEYCLOAK_API_ENVIRONMENT
value: ${KEYCLOAK_API_ENVIRONMENT}
- name: CHANGE_VERSION
value: ${CHANGE_ID}
- name: NODE_ENV
Expand Down
8 changes: 4 additions & 4 deletions api/src/services/gcnotify-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { getLogger } from '../utils/logger';
import { formatPhoneNumber, makeLoginUrl } from '../utils/string-utils';
import { ArtifactService } from './artifact-service';
import { DBService } from './db-service';
import { KeycloakService } from './keycloak-service';

export interface ISubmitArtifactRequestAccess {
fullName: string;
Expand Down Expand Up @@ -251,9 +250,10 @@ export class GCNotifyService extends DBService {
* @memberof GCNotifyService
*/
async getUserKeycloakEmail(userIdentifier: string, identitySource: string): Promise<string> {

Check warning on line 252 in api/src/services/gcnotify-service.ts

View workflow job for this annotation

GitHub Actions / Running Linter and Formatter

'userIdentifier' is defined but never used

Check warning on line 252 in api/src/services/gcnotify-service.ts

View workflow job for this annotation

GitHub Actions / Running Linter and Formatter

'identitySource' is defined but never used
const keycloakService = new KeycloakService();
const userDetails = await keycloakService.getUserByUsername(`${userIdentifier}@${identitySource}`);
return userDetails.email;
// const keycloakService = new KeycloakService();
// const userDetails = await keycloakService.getUserByUsername(`${userIdentifier}@${identitySource}`);
// return userDetails.email;
return Promise.resolve('');

Check warning on line 256 in api/src/services/gcnotify-service.ts

View check run for this annotation

Codecov / codecov/patch

api/src/services/gcnotify-service.ts#L256

Added line #L256 was not covered by tests
}

/**
Expand Down
Loading

0 comments on commit 8fe0002

Please sign in to comment.