-
Notifications
You must be signed in to change notification settings - Fork 177
Consolidate custom_domain and tre_url settings into single tre_url setting #4631
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
base: main
Are you sure you want to change the base?
Changes from all commits
389754a
59b3476
51a2d65
054a60a
d51066a
b459ddc
647e657
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -109,8 +109,8 @@ | |||||||
| "description": "SKU of the Azure Bastion.", | ||||||||
| "type": "string" | ||||||||
| }, | ||||||||
| "custom_domain": { | ||||||||
| "description": "Custom domain name.", | ||||||||
| "tre_url": { | ||||||||
| "description": "Custom TRE URL (full URL including https://). If not specified, will be constructed automatically.", | ||||||||
| "type": "string" | ||||||||
|
||||||||
| "type": "string" | |
| "type": "string", | |
| "pattern": "^https?://.+[^/]$" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| __version__ = "0.16.3" | ||
| __version__ = "0.17.0" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,13 @@ set -euo pipefail | |
|
|
||
| # AZURE_CORE_OUTPUT=jsonc # force CLI output to JSON for the script (user can still change default for interactive usage in the dev container) | ||
|
|
||
| # Get the directory that this script is in | ||
| SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" | ||
|
|
||
| # Source the helper function for extracting domain from URL | ||
| # shellcheck disable=SC1091 | ||
| source "${SCRIPT_DIR}/../extract_domain_from_url.sh" | ||
|
|
||
| function show_usage() | ||
| { | ||
| cat << USAGE | ||
|
|
@@ -18,14 +25,15 @@ Usage: $0 -n <app-name> [-r <reply-url>] [-a] [-s] [--automation-account] | |
| Options: | ||
| -n,--name Required. The prefix for the app (registration) names e.g., "TRE", or "Workspace One". | ||
| -u,--tre-url TRE URL, used to construct auth redirection URLs for the UI and Swagger app. | ||
| If the URL contains a custom domain, it will be used automatically. | ||
| -a,--admin-consent Optional, but recommended. Grants admin consent for the app registrations, when this flag is set. | ||
| Requires directory admin privileges to the Azure AD in question. | ||
| -t,--automation-clientid Optional, when --workspace is specified the client ID of the automation account can be added to the TRE workspace. | ||
| -r,--reset-password Optional, switch to automatically reset the password. Default 0 | ||
| -d,--custom-domain Optional, custom domain, used to construct auth redirection URLs (in addition to --tre-url) | ||
|
|
||
|
Comment on lines
25
to
33
|
||
| Examples: | ||
| 1. $0 -n TRE -r https://mytre.region.cloudapp.azure.com -a | ||
| 1. $0 -n TRE -u https://mytre.region.cloudapp.azure.com -a | ||
| 2. $0 -n TRE -u https://mytre.example.com -a (with custom domain) | ||
|
|
||
| Using an Automation account | ||
| 3. $0 --name 'TRE' --tre-url https://mytre.region.cloudapp.azure.com --admin-consent --automation-account | ||
|
|
@@ -59,7 +67,6 @@ declare automationAppId="" | |
| declare automationAppObjectId="" | ||
| declare msGraphUri="" | ||
| declare spPassword="" | ||
| declare customDomain="" | ||
|
|
||
| # Initialize parameters specified from command line | ||
| while [[ $# -gt 0 ]]; do | ||
|
|
@@ -84,10 +91,6 @@ while [[ $# -gt 0 ]]; do | |
| resetPassword=$2 | ||
| shift 2 | ||
| ;; | ||
| -d|--custom-domain) | ||
| customDomain=$2 | ||
| shift 2 | ||
| ;; | ||
| *) | ||
| echo "Invalid option: $1." | ||
| show_usage | ||
|
|
@@ -249,11 +252,14 @@ redirectUris="\"http://localhost:8000/api/docs/oauth2-redirect\", \"http://local | |
| if [[ -n ${treUrl} ]]; then | ||
| echo "Adding reply/redirect URL \"${treUrl}\" to \"${appName}\"" | ||
| redirectUris="${redirectUris}, \"${treUrl}\", \"${treUrl}/api/docs/oauth2-redirect\"" | ||
|
Comment on lines
252
to
254
|
||
| fi | ||
| if [[ -n ${customDomain} ]]; then | ||
| customDomainUrl="https://${customDomain}" | ||
| echo "Adding reply/redirect URL \"${customDomainUrl}\" to \"${appName}\"" | ||
| redirectUris="${redirectUris}, \"${customDomainUrl}\", \"${customDomainUrl}/api/docs/oauth2-redirect\"" | ||
|
|
||
| # Check if this is a custom domain (not the default cloudapp.azure.com pattern) | ||
| # If so, we don't need to add it again as it's already the main URL | ||
| treUrlDomain=$(extract_domain_from_url "${treUrl}") | ||
| if [[ "${treUrlDomain}" != *".cloudapp.azure.com" && "${treUrlDomain}" != *".cloudapp.usgovcloudapi.net" ]]; then | ||
| echo "Detected custom domain in TRE URL: ${treUrlDomain}" | ||
| # The custom domain URL is already included as the main treUrl, no need to add separately | ||
| fi | ||
| fi | ||
|
|
||
| uxAppDefinition=$(jq -c . << JSON | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| #!/bin/bash | ||
|
|
||
| # This script is designed to be `source`d to create reusable helper functions | ||
|
|
||
|
Comment on lines
+1
to
+4
|
||
| function extract_domain_from_url() | ||
| { | ||
| url=$1 | ||
|
|
||
| # Remove protocol (http:// or https://) | ||
| domain=$(echo "$url" | sed -E 's|^https?://||') | ||
|
|
||
| # Remove path and query parameters (everything after the first /) | ||
| domain=${domain%%/*} | ||
|
|
||
| # Remove port if present (everything after the first :) | ||
| domain=${domain%%:*} | ||
|
Comment on lines
+5
to
+16
|
||
|
|
||
| echo "$domain" | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -11,6 +11,8 @@ set -o nounset | |||||||||||||||||||||||||||||||
| # shellcheck disable=SC1091 | ||||||||||||||||||||||||||||||||
| source "${DIR}"/construct_tre_url.sh | ||||||||||||||||||||||||||||||||
| # shellcheck disable=SC1091 | ||||||||||||||||||||||||||||||||
| source "${DIR}"/extract_domain_from_url.sh | ||||||||||||||||||||||||||||||||
| # shellcheck disable=SC1091 | ||||||||||||||||||||||||||||||||
| source "${DIR}"/convert_azure_env_to_arm_env.sh | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| if [ ! -f "config.yaml" ]; then | ||||||||||||||||||||||||||||||||
|
|
@@ -88,8 +90,21 @@ else | |||||||||||||||||||||||||||||||
| export ARM_ENVIRONMENT | ||||||||||||||||||||||||||||||||
| export TF_VAR_arm_environment="${ARM_ENVIRONMENT}" | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| TRE_URL=$(construct_tre_url "${TRE_ID}" "${LOCATION}" "${AZURE_ENVIRONMENT}") | ||||||||||||||||||||||||||||||||
| # Set TRE_URL - either from config or constructed automatically | ||||||||||||||||||||||||||||||||
| if [[ -n "${TRE_URL:-}" ]]; then | ||||||||||||||||||||||||||||||||
| # TRE_URL was provided in config, use it as-is | ||||||||||||||||||||||||||||||||
| echo "Using TRE_URL from config: ${TRE_URL}" | ||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||
| # Construct TRE_URL automatically | ||||||||||||||||||||||||||||||||
| TRE_URL=$(construct_tre_url "${TRE_ID}" "${LOCATION}" "${AZURE_ENVIRONMENT}") | ||||||||||||||||||||||||||||||||
|
Comment on lines
+95
to
+99
|
||||||||||||||||||||||||||||||||
| # TRE_URL was provided in config, use it as-is | |
| echo "Using TRE_URL from config: ${TRE_URL}" | |
| else | |
| # Construct TRE_URL automatically | |
| TRE_URL=$(construct_tre_url "${TRE_ID}" "${LOCATION}" "${AZURE_ENVIRONMENT}") | |
| # TRE_URL was provided in config, normalize it | |
| TRE_URL="$(echo "${TRE_URL}" | xargs)" # trim leading/trailing whitespace | |
| TRE_URL="${TRE_URL%/}" # remove trailing slash, if any | |
| echo "Using TRE_URL from config: ${TRE_URL}" | |
| else | |
| # Construct TRE_URL automatically | |
| TRE_URL=$(construct_tre_url "${TRE_ID}" "${LOCATION}" "${AZURE_ENVIRONMENT}") | |
| # Normalize constructed TRE_URL as well, for consistency | |
| TRE_URL="$(echo "${TRE_URL}" | xargs)" # trim leading/trailing whitespace | |
| TRE_URL="${TRE_URL%/}" # remove trailing slash, if any |
Uh oh!
There was an error while loading. Please reload this page.