Skip to content

Commit cf29c8c

Browse files
feat(RHIDP-9113): add username change for validation \
creadentail changes for new database of keycloak \ additional config to sync the catalog to RHDH Signed-off-by: skestwal <skestwal@redhat.com>
1 parent dea5512 commit cf29c8c

File tree

5 files changed

+57
-5
lines changed

5 files changed

+57
-5
lines changed

ci-scripts/rhdh-setup/create_resource.sh

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ create_user() {
443443
groups="$groups]"
444444
while ((attempt <= max_attempts)); do
445445
token=$(get_token)
446-
username="t${0}"
446+
username="t_${0}"
447447
response="$(curl -s -k --location --request POST "$(keycloak_url)/admin/realms/backstage/users" \
448448
-H 'Content-Type: application/json' \
449449
-H 'Authorization: Bearer '"$token" \
@@ -499,7 +499,13 @@ log_token_err() {
499499
}
500500

501501
keycloak_token() {
502-
curl -s -k "$(keycloak_url)/realms/master/protocol/openid-connect/token" -d username=admin -d "password=$1" -d 'grant_type=password' -d 'client_id=admin-cli' | jq -r ".expires_in_timestamp = $(python3 -c 'from datetime import datetime, timedelta; t_add=int(30); print(int((datetime.now() + timedelta(seconds=t_add)).timestamp()))')"
502+
client_secret=$(oc -n "${RHDH_NAMESPACE}" get secret keycloak-client-secret-backstage -o template --template='{{.data.CLIENT_SECRET}}' | base64 -d)
503+
curl -s -k "$(keycloak_url)/realms/backstage/protocol/openid-connect/token" \
504+
-d username=guru \
505+
-d "password=$1" \
506+
-d 'grant_type=password' \
507+
-d 'client_id=backstage' \
508+
-d "client_secret=$client_secret" | jq -r ".expires_in_timestamp = $(python3 -c 'from datetime import datetime, timedelta; t_add=int(30); print(int((datetime.now() + timedelta(seconds=t_add)).timestamp()))')"
503509
}
504510

505511
rhdh_token() {
@@ -588,7 +594,7 @@ get_token() {
588594
log_token_err "Unable to get $token_type token, re-attempting"
589595
fi
590596
else
591-
keycloak_pass=$(oc -n "${RHDH_NAMESPACE}" get secret credential-rhdh-keycloak -o template --template='{{.data.ADMIN_PASSWORD}}' | base64 -d)
597+
keycloak_pass=$(oc -n "${RHDH_NAMESPACE}" get secret perf-test-secrets -o template --template='{{.data.keycloak_user_pass}}' | base64 -d)
592598
if ! keycloak_token "$keycloak_pass" >"$token_file"; then
593599
log_token_err "Unable to get $token_type token, re-attempting"
594600
fi

ci-scripts/rhdh-setup/deploy.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ export GROUP_COUNT="${GROUP_COUNT:-1}"
6161
export API_COUNT="${API_COUNT:-1}"
6262
export COMPONENT_COUNT="${COMPONENT_COUNT:-1}"
6363
export KEYCLOAK_USER_PASS=${KEYCLOAK_USER_PASS:-$(mktemp -u XXXXXXXXXX)}
64+
export KEYCLOAK_ADMIN_PASS=${KEYCLOAK_ADMIN_PASS:-admin}
6465
export AUTH_PROVIDER="${AUTH_PROVIDER:-''}"
6566
export ENABLE_RBAC="${ENABLE_RBAC:-false}"
6667
export ENABLE_ORCHESTRATOR="${ENABLE_ORCHESTRATOR:-false}"
@@ -256,7 +257,7 @@ keycloak_install() {
256257
wait_to_start statefulset rhdh-keycloak 450 600
257258

258259
$clin create secret generic credential-rhdh-keycloak \
259-
--from-literal=ADMIN_PASSWORD=admin \
260+
--from-literal=ADMIN_PASSWORD="$KEYCLOAK_ADMIN_PASS" \
260261
--dry-run=client -o yaml | $clin apply -f -
261262

262263
$clin create route edge keycloak \
@@ -274,7 +275,7 @@ keycloak_install() {
274275
fi
275276
fi
276277
# shellcheck disable=SC2016
277-
envsubst '${KEYCLOAK_CLIENT_SECRET} ${OAUTH2_REDIRECT_URI} ${KEYCLOAK_USER_PASS}' <template/keycloak/keycloakRealmImport.yaml | $clin apply -f -
278+
envsubst '${KEYCLOAK_CLIENT_SECRET} ${OAUTH2_REDIRECT_URI} ${KEYCLOAK_USER_PASS} ${KEYCLOAK_ADMIN_PASS}' <template/keycloak/keycloakRealmImport.yaml | $clin apply -f -
278279
$clin create secret generic keycloak-client-secret-backstage --from-literal=CLIENT_ID=backstage --from-literal=CLIENT_SECRET="$KEYCLOAK_CLIENT_SECRET" --dry-run=client -o yaml | oc apply -f -
279280
}
280281

ci-scripts/rhdh-setup/template/backstage/helm/chart-values.image-override.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,25 @@ global:
88
plugins:
99
- package: ./dynamic-plugins/dist/backstage-community-plugin-catalog-backend-module-keycloak-dynamic
1010
disabled: false
11+
pluginConfig:
12+
catalog:
13+
providers:
14+
keycloakOrg:
15+
default:
16+
baseUrl: ${KEYCLOAK_BASE_URL}
17+
realm: ${KEYCLOAK_REALM}
18+
loginRealm: ${KEYCLOAK_LOGIN_REALM}
19+
clientId: ${CLIENT_ID}
20+
clientSecret: ${CLIENT_SECRET}
21+
userQuerySize: 1000
22+
groupQuerySize: 1000
23+
schedule:
24+
frequency:
25+
minutes: 30
26+
timeout:
27+
minutes: 1
28+
initialDelay:
29+
seconds: 15
1130
- package: ./dynamic-plugins/dist/backstage-community-plugin-analytics-provider-segment
1231
disabled: true
1332
# TechDocs

ci-scripts/rhdh-setup/template/backstage/helm/chart-values.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,25 @@ global:
88
plugins:
99
- package: ./dynamic-plugins/dist/backstage-community-plugin-catalog-backend-module-keycloak-dynamic
1010
disabled: false
11+
pluginConfig:
12+
catalog:
13+
providers:
14+
keycloakOrg:
15+
default:
16+
baseUrl: ${KEYCLOAK_BASE_URL}
17+
realm: ${KEYCLOAK_REALM}
18+
loginRealm: ${KEYCLOAK_LOGIN_REALM}
19+
clientId: ${CLIENT_ID}
20+
clientSecret: ${CLIENT_SECRET}
21+
userQuerySize: 1000
22+
groupQuerySize: 1000
23+
schedule:
24+
frequency:
25+
minutes: 30
26+
timeout:
27+
minutes: 1
28+
initialDelay:
29+
seconds: 15
1130
- package: ./dynamic-plugins/dist/backstage-community-plugin-analytics-provider-segment
1231
disabled: true
1332
# TechDocs

ci-scripts/rhdh-setup/template/keycloak/keycloakRealmImport.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ spec:
3131
- query-groups
3232
- query-users
3333
- view-users
34+
- view-clients
35+
- view-realm
36+
- manage-users
37+
- manage-clients
3438
users:
3539
- username: guru
3640
firstName: Guru
@@ -42,3 +46,6 @@ spec:
4246
- type: password
4347
value: ${KEYCLOAK_USER_PASS}
4448
temporary: false
49+
clientRoles:
50+
realm-management:
51+
- realm-admin

0 commit comments

Comments
 (0)