-
Notifications
You must be signed in to change notification settings - Fork 474
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved the generation of the cognito config to a separate script file that can be called during the site creation. Change-Id: I33e2ecd2bf40ce2cb3682b63a45f49c501b3f7d1
- Loading branch information
1 parent
2d1ae03
commit b6dd983
Showing
2 changed files
with
28 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/usr/bin/env bash | ||
# Generate and print the cognito idp config for the SaaS edition | ||
|
||
IDP_URL="${1-http://localhost:5551}" | ||
BASE_URL="${2:-http://localhost:5000}" | ||
CLIENT_ID="${3:-notused}" | ||
TENANT_ID="${4:-123tenant567}" | ||
|
||
# Create JSON object | ||
printf '{\n "%s":"%s",\n "%s":"%s",\n "%s":"%s",\n "%s":"%s",\n "%s":"%s",\n "%s":"%s"\n}' \ | ||
"client_id" "$CLIENT_ID" \ | ||
"base_url" "$BASE_URL" \ | ||
"saas_api_url" "$IDP_URL" \ | ||
"tenant_id" "$TENANT_ID" \ | ||
"logout_url" "$IDP_URL/logout" \ | ||
"well_known" "$IDP_URL/.well-known/openid-configuration" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,22 @@ | ||
#!/bin/bash | ||
# | ||
#!/usr/bin/env bash | ||
# Launch a cognito idp for the SaaS edition | ||
set -e | ||
|
||
REPO_PATH="$(dirname "$(dirname "$(realpath "$0")")")" | ||
|
||
# acquire sudo to run to change the configuration | ||
sudo true | ||
|
||
configure_cognito() { | ||
idp_url="$1" | ||
checkmk_port="$2" | ||
|
||
client_id="notused" | ||
base_url="http://localhost:$checkmk_port" | ||
well_known="$idp_url/.well-known/openid-configuration" | ||
|
||
# Create JSON object | ||
JSON=$(printf '{\n "%s":"%s",\n "%s":"%s",\n "%s":"%s",\n "%s":"%s",\n "%s":"%s",\n "%s":"%s"\n}' \ | ||
"client_id" "$client_id" \ | ||
"base_url" "$base_url" \ | ||
"saas_api_url" "$idp_url" \ | ||
"tenant_id" "123tenant567" \ | ||
"logout_url" "$idp_url/logout" \ | ||
"well_known" "$well_known") | ||
|
||
# Write JSON object to file | ||
sudo mkdir -p /etc/cse | ||
echo "$JSON" | sudo tee /etc/cse/cognito-cmk.json >/dev/null | ||
} | ||
|
||
PORT=5551 | ||
# URL under which we can reach the openid provider | ||
# PORT and URL under which we can reach the openid provider | ||
PORT=${1:-5551} | ||
export URL="http://localhost:${PORT}" | ||
|
||
# checkmk uses port 5000 by default | ||
configure_cognito $URL 5000 | ||
# URL of the checkmk instance; checkmk uses port 5000 by default | ||
CMK_URL="http://localhost:${2:-5000}" | ||
|
||
# Write cognito configuration file | ||
sudo mkdir -p /etc/cse | ||
"$(dirname "$0")/create_cognito_config_cse.sh" "${URL}" "${CMK_URL}" | sudo tee /etc/cse/cognito-cmk.json >/dev/null | ||
|
||
export PYTHONPATH="${REPO_PATH}/tests/testlib" | ||
"$REPO_PATH"/scripts/run-pipenv run uvicorn cse.openid_oauth_provider:application --port "$PORT" | ||
export PYTHONPATH="${REPO_PATH}:${REPO_PATH}/tests/testlib" | ||
"${REPO_PATH}/scripts/run-pipenv" run uvicorn cse.openid_oauth_provider:application --port "${PORT}" |