Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GRAD2-3037 - adds new service client secret #309

Merged
merged 1 commit into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions api/src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ spring:
client:
registration:
graduation-report-client:
client-id: ${GRADUATION_REPORT_API_CLIENT_NAME}
client-secret: ${GRADUATION_REPORT_API_CLIENT_SECRET}
client-id: ${GRAD_GRADUATION_REPORT_API_CLIENT_NAME}
client-secret: ${GRAD_GRADUATION_REPORT_API_CLIENT_SECRET}
authorization-grant-type: client_credentials
provider:
graduation-report-client:
Expand Down
32 changes: 32 additions & 0 deletions tools/config/update-configmap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ COMMON_NAMESPACE=$4
BUSINESS_NAMESPACE=$5
SPLUNK_TOKEN=$6
APP_LOG_LEVEL=$7
CLIENT_SECRET_NAME=grad-graduation-report-api-client-secret

SPLUNK_URL="gww.splunk.educ.gov.bc.ca"
FLB_CONFIG="[SERVICE]
Expand Down Expand Up @@ -70,3 +71,34 @@ oc create -n "$GRAD_NAMESPACE"-"$envValue" configmap "$APP_NAME"-flb-sc-config-m
--from-literal=parsers.conf="$PARSER_CONFIG" \
--dry-run=client -o yaml | oc apply -f -

SOAM_KC_LOAD_USER_ADMIN=$(oc -n $COMMON_NAMESPACE-$envValue -o json get secret sso-admin-${envValue} | sed -n 's/.*"username": "\(.*\)"/\1/p' | base64 --decode)
SOAM_KC_LOAD_USER_PASS=$(oc -n $COMMON_NAMESPACE-$envValue -o json get secret sso-admin-${envValue} | sed -n 's/.*"password": "\(.*\)",/\1/p' | base64 --decode)
SOAM_KC=soam-$envValue.apps.silver.devops.gov.bc.ca
SOAM_KC_REALM_ID="master"

echo Fetching SOAM token
TKN=$(curl -s \
-d "client_id=admin-cli" \
-d "username=$SOAM_KC_LOAD_USER_ADMIN" \
-d "password=$SOAM_KC_LOAD_USER_PASS" \
-d "grant_type=password" \
"https://$SOAM_KC/auth/realms/$SOAM_KC_REALM_ID/protocol/openid-connect/token" | jq -r '.access_token')

echo Retrieving client ID for grad-graduation-report-api-service
CLIENT_UUID=$(curl -sX GET "https://$SOAM_KC/auth/admin/realms/$SOAM_KC_REALM_ID/clients" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $TKN" |
jq '.[] | select(.clientId=="'"$CLIENT_ID"'")' | jq -r '.id')

echo
echo Retrieving client secret for grad-graduation-report-api-service
SERVICE_CLIENT_SECRET=$(curl -sX GET "https://$SOAM_KC/auth/admin/realms/$SOAM_KC_REALM_ID/clients/$CLIENT_UUID/client-secret" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $TKN" |
jq -r '.value')

echo Creating secret for client
oc create -n "$GRAD_NAMESPACE"-"$envValue" secret generic $CLIENT_SECRET_NAME \
--from-literal=GRAD_GRADUATION_REPORT_API_CLIENT_NAME="$CLIENT_ID" \
--from-literal=GRAD_GRADUATION_REPORT_API_CLIENT_SECRET="$SERVICE_CLIENT_SECRET" \
--dry-run=client -o yaml | oc apply -f -
Loading