Skip to content

Integrate Azure App Service authentication with React frontend#57

Merged
fpittelo merged 5 commits intodevfrom
copilot/create-react-login-page
Nov 22, 2025
Merged

Integrate Azure App Service authentication with React frontend#57
fpittelo merged 5 commits intodevfrom
copilot/create-react-login-page

Conversation

Copy link
Contributor

Copilot AI commented Nov 22, 2025

The deployed app returns "Unauthorized client" because Azure App Service auth is enabled but the React frontend doesn't integrate with the infrastructure-level authentication endpoints.

Changes

Frontend Authentication Flow

  • LoginPage: Wire buttons to Azure's built-in auth endpoints (/.auth/login/google, /.auth/login/aad)
  • App: Check auth state via /.auth/me, conditionally render LoginPage or HomePage
  • HomePage: New component for authenticated users with logout via /.auth/logout
// Before: static buttons
<button className="google-login">Login with Google</button>

// After: redirect to Azure App Service auth
<button onClick={() => window.location.href = '/.auth/login/google?post_login_redirect_uri=/'}>
  Login with Google
</button>

Deployment Pipeline

  • Add Node.js 18 setup, npm build, and Azure Web App deployment to GitHub Actions workflow

OAuth Configuration Required

Authentication requires OAuth apps configured with redirect URIs:

  • Google: https://{env}-alpinebot-as.azurewebsites.net/.auth/login/google/callback
  • Microsoft: https://{env}-alpinebot-as.azurewebsites.net/.auth/login/aad/callback

See OAUTH_SETUP.md for complete setup instructions. GitHub secrets must be set: GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET, MICROSOFT_CLIENT_ID, MICROSOFT_CLIENT_SECRET.

Original prompt

This section details on the original issue you should resolve

<issue_title>Task 1.2.1: Create a basic React application with a login page, inspired by the minimalist design.</issue_title>
<issue_description>Task 1.2.1: Create a basic React application with a login page, inspired by the minimalist design.</issue_description>

<agent_instructions>Read plan.md. We are at Milestone 1.2, task 1.2.1. NPM has been installed and a minimal webiste created. However the site give an error message when accessed.: Unauthorized client.</agent_instructions>

Comments on the Issue (you are @copilot in this section)

@fpittelo **Milestone 1.2: Frontend Authentication UI** * [ ] **Task 1.2.1:** Create a basic React application with a login page, inspired by the minimalist design. *(in progress, manual `npm install` and background image setup required)* * NPM install is done * After deployment, when accessing the project dev website dev-alpinebot-as.azurewebsites.net I get this error - We're unable to complete your request: unauthorized client: The client does not exist or is not enabled for consumers. If you are the application developer, configure a new application through the App Registrations in the Azure Portal at https://go.microsoft.com/fwlink/?linkid=2083908.

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 4 commits November 22, 2025 10:32
Co-authored-by: fpittelo <3135901+fpittelo@users.noreply.github.com>
Co-authored-by: fpittelo <3135901+fpittelo@users.noreply.github.com>
…ation

Co-authored-by: fpittelo <3135901+fpittelo@users.noreply.github.com>
Co-authored-by: fpittelo <3135901+fpittelo@users.noreply.github.com>
Copilot AI changed the title [WIP] Create a basic React application with login page Integrate Azure App Service authentication with React frontend Nov 22, 2025
Copilot AI requested a review from fpittelo November 22, 2025 10:39
@fpittelo fpittelo marked this pull request as ready for review November 22, 2025 10:40
@fpittelo
Copy link
Owner

Seems ok

@fpittelo fpittelo merged commit 6ff147b into dev Nov 22, 2025
@fpittelo fpittelo deleted the copilot/create-react-login-page branch November 22, 2025 10:53
@fpittelo
Copy link
Owner

@copilot deployment caused the following error :

Run azure/webapps-deploy@v2
with:
app-name: dev-alpinebot-as
package: ./frontend/app/build
slot-name: production
env:
ENVIRONMENT: dev
TF_VAR_az_client_id: ***
TF_VAR_az_tenant_id: ***
TF_VAR_az_subscription_id: ***
TF_VAR_az_container_name: dev-bkd-alpinebot-co
TF_VAR_sp_object_id:
TF_VAR_az_openai_key_value: ***
TF_VAR_postgresql_admin_password: ***
TF_VAR_postgresql_admin_username: ***
TF_VAR_google_client_id: ***
TF_VAR_google_client_secret: ***
TF_VAR_microsoft_client_id: ***
TF_VAR_microsoft_client_secret: ***
TERRAFORM_CLI_PATH: /home/runner/work/_temp/34c0a7b3-5f29-47a6-9041-d0a9d16b21e4
Package deployment using ZIP Deploy initiated.
Updating submodules.
Preparing deployment for commit id '4e02a53f-4'.
PreDeployment: context.CleanOutputPath False
PreDeployment: context.OutputPath /home/site/wwwroot
Generating deployment script.
Running deployment command...
Command: /opt/Kudu/Scripts/parallel_rsync.sh /tmp/zipdeploy/extracted /home/site/wwwroot 8 /tmp/ False True
Run rsync from: /tmp/zipdeploy/extracted/ to: /home/site/wwwroot/ in 8 parallel threads
Delete options: clean=False, use manifest=True, directory to ignore=
Prev manifest = /opt/Kudu/Scripts/firstDeploymentManifest and next /home/site/deployments/4e02a53f-4c9f-4f51-9f25-e87070d71c1a/manifest
Cleaning up /tmp//filelist.txt and /tmp//splits
Creating a list of all files at /tmp//filelist.txt
No directory to exclude.
Created /tmp//filelist.txt. Total number of files to be synced = 9.
Created batches from the list of files. Processing 2 files in each thread
Running rsync for filelist /tmp//splits/split.aa from /tmp/zipdeploy/extracted/ to /home/site/wwwroot/
Running rsync for filelist /tmp//splits/split.ac from /tmp/zipdeploy/extracted/ to /home/site/wwwroot/
Running rsync for filelist /tmp//splits/split.ab from /tmp/zipdeploy/extracted/ to /home/site/wwwroot/
Running rsync for filelist /tmp//splits/split.ad from /tmp/zipdeploy/extracted/ to /home/site/wwwroot/
Running rsync for filelist /tmp//splits/split.ae from /tmp/zipdeploy/extracted/ to /home/site/wwwroot/

Number of files: 1 (reg: 1)
Number of created files: 1 (reg: 1)
Number of deleted files: 0
Number of regular files transferred: 1
Total file size: 644 bytes
Total transferred file size: 644 bytes
Literal data: 644 bytes
Matched data: 0 bytes
File list size: 0
File list generation time: 0.018 seconds
File list transfer time: 0.000 seconds
Total bytes sent: 533
Total bytes received: 35

sent 533 bytes received 35 bytes 162.29 bytes/sec
total size is 644 speedup is 1.13

Number of files: 2 (reg: 2)
Number of created files: 2 (reg: 2)
Number of deleted files: 0
Number of regular files transferred: 2
Total file size: 935 bytes
Total transferred file size: 935 bytes
Literal data: 935 bytes
Matched data: 0 bytes
File list size: 0
File list generation time: 0.008 seconds
File list transfer time: 0.000 seconds
Total bytes sent: 652
Total bytes received: 54

sent 652 bytes received 54 bytes 201.71 bytes/sec
total size is 935 speedup is 1.32
Attempt 1: Rsync for filelist /tmp//splits/split.ad completed with exit code 0
Attempt 1: Rsync for filelist /tmp//splits/split.ae completed with exit code 0

Number of files: 4 (reg: 2, dir: 2)
Number of created files: 3 (reg: 2, dir: 1)
Number of deleted files: 0
Number of regular files transferred: 2
Total file size: 7.94K bytes
Total transferred file size: 7.94K bytes
Literal data: 7.94K bytes
Matched data: 0 bytes
File list size: 0
File list generation time: 0.019 seconds
File list transfer time: 0.000 seconds
Total bytes sent: 2.59K
Total bytes received: 60

sent 2.59K bytes received 60 bytes 756.57 bytes/sec
total size is 7.94K speedup is 3.00
Attempt 1: Rsync for filelist /tmp//splits/split.aa completed with exit code 0

Number of files: 4 (reg: 2, dir: 2)
Number of created files: 4 (reg: 2, dir: 2)
Number of deleted files: 0
Number of regular files transferred: 2
Total file size: 143.97K bytes
Total transferred file size: 143.97K bytes
Literal data: 143.97K bytes
Matched data: 0 bytes
File list size: 0
File list generation time: 0.106 seconds
File list transfer time: 0.000 seconds
Total bytes sent: 48.47K
Total bytes received: 60

sent 48.47K bytes received 60 bytes 13.86K bytes/sec
total size is 143.97K speedup is 2.97
Attempt 1: Rsync for filelist /tmp//splits/split.ab completed with exit code 0

Number of files: 5 (reg: 2, dir: 3)
Number of created files: 3 (reg: 2, dir: 1)
Number of deleted files: 0
Number of regular files transferred: 2
Total file size: 1.68M bytes
Total transferred file size: 1.68M bytes
Literal data: 1.68M bytes
Matched data: 0 bytes
File list size: 0
File list generation time: 0.010 seconds
File list transfer time: 0.000 seconds
Total bytes sent: 1.44M
Total bytes received: 63

sent 1.44M bytes received 63 bytes 262.29K bytes/sec
total size is 1.68M speedup is 1.17
Attempt 1: Rsync for filelist /tmp//splits/split.ac completed with exit code 0
Deleting files not present in /tmp/zipdeploy/extracted/ from /home/site/wwwroot/ based on manifest file /opt/Kudu/Scripts/firstDeploymentManifest
Number of files deleted: 1. See /tmp//rsync_deletion_logs.txt for more details.
create new manifest file at /home/site/deployments/4e02a53f-4c9f-4f51-9f25-e87070d71c1a/manifest
Error: Failed to deploy web package to App Service.
Error: Deployment Failed, Package deployment using ZIP Deploy failed. Refer logs for more details.
App Service Application URL: http://dev-alpinebot-as.azurewebsites.net/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Task 1.2.1: Create a basic React application with a login page, inspired by the minimalist design.

2 participants