diff --git a/ccp/modules/datashield-setup.sh b/ccp/modules/datashield-setup.sh index 5f8fac4..420a450 100644 --- a/ccp/modules/datashield-setup.sh +++ b/ccp/modules/datashield-setup.sh @@ -23,5 +23,5 @@ if [ "$ENABLE_DATASHIELD" == true ]; then }]' > /tmp/bridgehead/opal-map/local.json cp -f ./$PROJECT/modules/datashield-mappings.json /tmp/bridgehead/opal-map/central.json chown -R bridgehead:docker /tmp/bridgehead/ - generate_private_oidc_client "OIDC_CLIENT_SECRET" "https://${HOST}/opal/*" + generate_private_oidc_client "OIDC_CLIENT_SECRET" "$(generate_redirect_urls '/opal/*')" fi diff --git a/ccp/modules/teiler-setup.sh b/ccp/modules/teiler-setup.sh index 17b19bd..0da6f6f 100644 --- a/ccp/modules/teiler-setup.sh +++ b/ccp/modules/teiler-setup.sh @@ -3,10 +3,5 @@ if [ "$ENABLE_TEILER" == true ];then log INFO "Teiler setup detected -- will start Teiler services." OVERRIDE+=" -f ./$PROJECT/modules/teiler-compose.yml" - redirect_urls="https://${HOST}/ccp-teiler/*" - host_without_proxy="$(echo "$HOST" | cut -d '.' -f1)" - if [[ "$HOST" != "$host_without_proxy" ]]; then - redirect_urls+=",https://$host_without_proxy/ccp-teiler/*" - fi - generate_public_oidc_client "OIDC_PUBLIC" "$redirect_urls" + generate_public_oidc_client "OIDC_PUBLIC" "$(generate_redirect_urls '/ccp-teiler/*')" fi diff --git a/lib/functions.sh b/lib/functions.sh index e0367e2..78317fd 100644 --- a/lib/functions.sh +++ b/lib/functions.sh @@ -292,3 +292,18 @@ capitalize_first_letter() { capitalized="$(tr '[:lower:]' '[:upper:]' <<< ${input:0:1})${input:1}" echo "$capitalized" } + +generate_redirect_urls(){ + local redirect_urls="https://${HOST}$1" + local host_without_proxy="$(echo "$HOST" | cut -d '.' -f1)" + local port="$(echo "$HOST" | rev | cut -d ':' -f1 | rev)" + if [ -z "${port}" ]; then + port="" + else + port=":$port" + fi + if [[ "$HOST" != "$host_without_proxy" ]]; then + redirect_urls+=",https://$host_without_proxy$port$1" + fi + echo "$redirect_urls" +}