Skip to content

Commit 7653de6

Browse files
commit
1 parent 4ac7817 commit 7653de6

11 files changed

Lines changed: 69 additions & 19 deletions

docs/ConfigureAppAuthentication.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,20 @@
44
>
55
> `azd up` no longer runs authentication setup automatically. Run the script below after deployment:
66
>
7-
> - Windows: `./infra/scripts/setup_auth.ps1`
8-
> - macOS/Linux: `sed -i 's/\r$//' ./infra/scripts/setup_auth.sh && bash ./infra/scripts/setup_auth.sh`
7+
> **Windows:**
8+
> ```powershell
9+
> ./infra/scripts/setup_auth.ps1
10+
> ```
911
>
10-
> See [DeploymentGuide.md § 5.3](./DeploymentGuide.md#53-configure-authentication-manual-script) for details.
12+
> **macOS/Linux:**
13+
> ```bash
14+
> # Remove Windows line endings and run the auth setup script
15+
> tr -d '\r' < ./infra/scripts/setup_auth.sh > ./infra/scripts/setup_auth.sh.tmp && \
16+
> mv ./infra/scripts/setup_auth.sh.tmp ./infra/scripts/setup_auth.sh && \
17+
> bash ./infra/scripts/setup_auth.sh
18+
> ```
19+
>
20+
> See [DeploymentGuide.md § 5.3](./DeploymentGuide.md#53-configure-authentication-manual-script) for step-by-step instructions.
1121
>
1222
> Follow the portal/manual steps below if:
1323
> - Your tenant policy prohibits programmatic app registration or secret creation

docs/DeploymentGuide.md

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -323,8 +323,13 @@ Run schema registration first to:
323323
**macOS/Linux:**
324324

325325
```bash
326-
sed -i 's/\r$//' ./infra/scripts/register_schemas.sh
327-
sed -i 's/\r$//' ./infra/scripts/post_deployment.sh
326+
normalize_script() {
327+
local file="$1"
328+
tr -d '\r' < "$file" > "${file}.tmp" && mv "${file}.tmp" "$file"
329+
}
330+
331+
normalize_script ./infra/scripts/register_schemas.sh
332+
normalize_script ./infra/scripts/post_deployment.sh
328333
bash ./infra/scripts/register_schemas.sh
329334
```
330335

@@ -348,8 +353,13 @@ After schema registration completes, upload the sample bundles as a separate exp
348353
**macOS/Linux:**
349354

350355
```bash
351-
sed -i 's/\r$//' ./infra/scripts/upload_sample_data.sh
352-
sed -i 's/\r$//' ./infra/scripts/post_deployment.sh
356+
normalize_script() {
357+
local file="$1"
358+
tr -d '\r' < "$file" > "${file}.tmp" && mv "${file}.tmp" "$file"
359+
}
360+
361+
normalize_script ./infra/scripts/upload_sample_data.sh
362+
normalize_script ./infra/scripts/post_deployment.sh
353363
bash ./infra/scripts/upload_sample_data.sh
354364
```
355365

@@ -366,8 +376,13 @@ Run authentication setup as an explicit step after post-deployment data setup:
366376
**macOS/Linux:**
367377

368378
```bash
369-
sed -i 's/\r$//' ./infra/scripts/setup_auth.sh
370-
sed -i 's/\r$//' ./infra/scripts/configure_auth.sh
379+
normalize_script() {
380+
local file="$1"
381+
tr -d '\r' < "$file" > "${file}.tmp" && mv "${file}.tmp" "$file"
382+
}
383+
384+
normalize_script ./infra/scripts/setup_auth.sh
385+
normalize_script ./infra/scripts/configure_auth.sh
371386
bash ./infra/scripts/setup_auth.sh
372387
```
373388

infra/scripts/configure_auth.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ echo " ✓ Web env vars: APP_WEB_CLIENT_ID / APP_WEB_SCOPE / APP_API_SCOPE / AP
573573

574574
# Patch both authConfigs:
575575
# - API: add Web client id to allowedApplications
576-
# - Both: reset allowedAudiences to only the clientId, normalize openIdIssuer
576+
# - Both: set allowedAudiences to clientId and its API scope variant, normalize openIdIssuer
577577
patch_authconfig() {
578578
local ca_name="$1"
579579
local client_id="$2"

infra/scripts/post_deployment.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,5 +415,5 @@ if (-not $ApiReady) {
415415
Write-Host ""
416416
Write-Host ("=" * 60)
417417
Write-Host "Post-deployment data setup completed."
418-
Write-Host "Next manual step: configure authentication using infra/scripts/configure_auth.ps1"
418+
Write-Host "Next manual step: configure authentication using infra/scripts/setup_auth.ps1"
419419
Write-Host ("=" * 60)

infra/scripts/post_deployment.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,5 +431,5 @@ fi
431431
echo ""
432432
echo "============================================================"
433433
echo "Post-deployment data setup completed."
434-
echo "Next manual step: configure authentication using infra/scripts/configure_auth.sh"
434+
echo "Next manual step: configure authentication using infra/scripts/setup_auth.sh"
435435
echo "============================================================"

infra/scripts/register_schemas.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@
22
set -euo pipefail
33

44
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5-
tmp_file="$(mktemp)" || { echo "Failed to create temp file" >&2; exit 1; }
5+
if ! tmp_file="$(mktemp "${TMPDIR:-/tmp}/cpsa-schema.XXXXXX" 2>/dev/null)"; then
6+
tmp_file="$(mktemp -t cpsa-schema.XXXXXX 2>/dev/null)" || {
7+
echo "Failed to create temp file" >&2
8+
exit 1
9+
}
10+
fi
611
if ! tr -d '\r' < "$SCRIPT_DIR/post_deployment.sh" > "$tmp_file"; then
712
rm -f "$tmp_file"
813
echo "Failed to normalize line endings for: $SCRIPT_DIR/post_deployment.sh" >&2

infra/scripts/run_post_deployment.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,12 @@ step_fail() { echo ""; echo " ❌ Step $1 failed — see errors above."; }
5353
normalize_line_endings() {
5454
local script_file="$1"
5555
local tmp_file
56-
tmp_file="$(mktemp)" || { echo " ❌ Failed to create temp file" >&2; exit 1; }
56+
if ! tmp_file="$(mktemp "${TMPDIR:-/tmp}/cpsa-postdeploy.XXXXXX" 2>/dev/null)"; then
57+
tmp_file="$(mktemp -t cpsa-postdeploy.XXXXXX 2>/dev/null)" || {
58+
echo " ❌ Failed to create temp file" >&2
59+
exit 1
60+
}
61+
fi
5762
if ! tr -d '\r' < "$script_file" > "$tmp_file"; then
5863
rm -f "$tmp_file"
5964
echo " ❌ Failed to normalize line endings for: $script_file" >&2

infra/scripts/setup_auth.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@
22
set -euo pipefail
33

44
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5-
tmp_file="$(mktemp)" || { echo "Failed to create temp file" >&2; exit 1; }
5+
if ! tmp_file="$(mktemp "${TMPDIR:-/tmp}/cpsa-auth.XXXXXX" 2>/dev/null)"; then
6+
tmp_file="$(mktemp -t cpsa-auth.XXXXXX 2>/dev/null)" || {
7+
echo "Failed to create temp file" >&2
8+
exit 1
9+
}
10+
fi
611
if ! tr -d '\r' < "$SCRIPT_DIR/configure_auth.sh" > "$tmp_file"; then
712
rm -f "$tmp_file"
813
echo "Failed to normalize line endings for: $SCRIPT_DIR/configure_auth.sh" >&2

infra/scripts/test_configure_auth_preflight.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,12 @@ $MockAzdPs1Content | Out-File -FilePath (Join-Path $TempDir "mock_azd.ps1") -Enc
128128
# Write .cmd wrappers — %~dp0 resolves to the directory containing the .cmd file
129129
@"
130130
@echo off
131-
powershell -NoProfile -NonInteractive -ExecutionPolicy Bypass -File "%~dp0mock_az.ps1" %*
131+
pwsh -NoProfile -NonInteractive -ExecutionPolicy Bypass -File "%~dp0mock_az.ps1" %*
132132
"@ | Out-File -FilePath (Join-Path $TempDir "az.cmd") -Encoding ASCII
133133

134134
@"
135135
@echo off
136-
powershell -NoProfile -NonInteractive -ExecutionPolicy Bypass -File "%~dp0mock_azd.ps1" %*
136+
pwsh -NoProfile -NonInteractive -ExecutionPolicy Bypass -File "%~dp0mock_azd.ps1" %*
137137
"@ | Out-File -FilePath (Join-Path $TempDir "azd.cmd") -Encoding ASCII
138138

139139
# =============================================================================

infra/scripts/test_configure_auth_preflight.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,12 @@ fi
2525
PASS_COUNT=0
2626
FAIL_COUNT=0
2727

28-
TEMP_DIR="$(mktemp -d)"
28+
if ! TEMP_DIR="$(mktemp -d "${TMPDIR:-/tmp}/configure_auth_preflight.XXXXXX" 2>/dev/null)"; then
29+
TEMP_DIR="$(mktemp -d -t configure_auth_preflight.XXXXXX 2>/dev/null)" || {
30+
echo "❌ Failed to create temp directory" >&2
31+
exit 1
32+
}
33+
fi
2934
trap 'rm -rf "$TEMP_DIR"' EXIT
3035

3136
# =============================================================================

0 commit comments

Comments
 (0)