Skip to content

fix: automatic token refresh, app view preview resolution, and AWS deployment automation - #8

Merged
ANUJ760 merged 6 commits into
ANUJ760:mainfrom
Adarsh2709:fix/auth-token-refresh-and-deployments
Sep 29, 2026
Merged

ANUJ760 merged 6 commits into
ANUJ760:mainfrom
Adarsh2709:fix/auth-token-refresh-and-deployments

Conversation

@Adarsh2709

Copy link
Copy Markdown
Collaborator

Summary of Changes

This pull request resolves authentication expiration issues, live app iframe preview routing, and adds automated AWS deployment pipelines for both backend and frontend.

1. Cognito Authentication & Auto-Refresh

  • Role Permission Fix: Default authenticated Cognito users to \editor\ role so they have permission to plan, deploy, and update apps without encountering \403 Forbidden.
  • Automatic Token Refresh: Implemented \getValidToken()\ in \ rontend/src/api/auth.ts\ using \cognitoUser.getSession(...). When a Cognito ID token expires after 1 hour, \�mazon-cognito-identity-js\ automatically uses the 30-day refresh token to request fresh credentials without interrupting user activity.
  • Central API Integration: Updated \ rontend/src/api/client.ts\ to await \getValidToken()\ before every request and automatically purge expired tokens on \401.

2. Live App View & Error Handling

  • Preview Resolution: Updated \ rontend/src/pages/AppView.tsx\ to resolve relative /apps/:id/live\ paths against \VITE_API_BASE_URL\ so the iframe loads from the FastAPI backend rather than 404ing against S3 static hosting.
  • Session Expiration Handling: When an update request encounters an expired session (\401), the UI displays a clear message (\Your session has expired. Redirecting to login...) and redirects to /login?return=/apps/.
  • Error Clarity: Shows specific backend error messages rather than generic failure notices.

3. AWS Deployment Automation

  • Backend Docker Build for Lambda: Added --provenance=false\ to \�ackend/deploy_aws.sh\ and created \deploy_backend_lambda.ps1\ for building and deploying to AWS Lambda with single-architecture manifest compliance.
  • Frontend S3 Deployment: Added \deploy_frontend_s3.ps1\ to sync environment variables, build the React production bundle, and deploy to AWS S3 Static Website Hosting.

Commits Included (6)

  1. \ ix(auth): default authenticated Cognito users to editor role for app deployments\
  2. \ ix(deploy): enforce single-architecture manifest in backend Docker build for AWS Lambda\
  3. \ eat(deploy): add automated AWS S3 deployment script for React frontend\
  4. \ ix(frontend/auth): implement automatic token refresh and session handling via Cognito\
  5. \ ix(frontend/client): integrate getValidToken in central API client and purge on 401\
  6. \ ix(frontend/app-view): resolve live app URLs and handle session expiration on app update\

Verification

  • Ran backend pytest suite: 126/126 tests passed.
  • Built frontend production bundle: \ sc && vite build\ succeeded with exit code 0.
  • Deployed frontend to AWS S3 and verified live attendance tracker app.

@ANUJ760
ANUJ760 merged commit f6e406f into ANUJ760:main Sep 29, 2026
2 checks passed
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.

2 participants