diff --git a/Makefile b/Makefile index 71c83e6a..9b4e59e3 100644 --- a/Makefile +++ b/Makefile @@ -21,10 +21,6 @@ GCP_STAGING_PROJECT_ID := krow-workforce-staging IAP_SERVICE_ACCOUNT := service-933560802882@gcp-sa-iap.iam.gserviceaccount.com # --- Cloud Run Configuration --- -CR_LAUNCHPAD_SERVICE_NAME := internal-launchpad -CR_LAUNCHPAD_REGION := us-central1 -CR_LAUNCHPAD_IMAGE_URI := us-docker.pkg.dev/$(GCP_DEV_PROJECT_ID)/gcr-io/$(CR_LAUNCHPAD_SERVICE_NAME) - CR_ADMIN_SERVICE_NAME := admin-console CR_ADMIN_REGION := us-central1 CR_ADMIN_IMAGE_URI = us-docker.pkg.dev/$(GCP_PROJECT_ID)/gcr-io/$(CR_ADMIN_SERVICE_NAME) @@ -68,6 +64,7 @@ help: @echo " make install - Installs web frontend dependencies." @echo " make dev - Starts the local web frontend server." @echo " make build - Builds the web frontend for production." + @echo " make launchpad-dev - Starts the local launchpad server (Firebase Hosting emulator)." @echo "" @echo " --- MOBILE APP DEVELOPMENT ---" @echo " make mobile-client-install - Install dependencies for client app" @@ -79,7 +76,7 @@ help: @echo " make mobile-staff-build - Build staff app (requires ENV & PLATFORM, optional BUILD_TYPE=apk)" @echo "" @echo " --- DEPLOYMENT ---" - @echo " make deploy-launchpad-full - Deploys internal launchpad to Cloud Run (dev only) with IAP." + @echo " make deploy-launchpad-hosting - Deploys internal launchpad to Firebase Hosting (Auth via Firebase)." @echo " make deploy-admin-full [ENV=staging] - Deploys Admin Console to Cloud Run with IAP (default: dev)." @echo " make deploy-app [ENV=staging] - Builds and deploys the main web app via Firebase Hosting (default: dev)." @echo "" @@ -125,29 +122,21 @@ build: @echo "--> Building web frontend for production..." @cd frontend-web && VITE_APP_ENV=$(ENV) npm run build -# --- Deployment --- -deploy-launchpad: - @echo "--> Building and deploying Internal Launchpad to Cloud Run..." - @echo " - Step 1: Building container image..." - @cd firebase/internal-launchpad && gcloud builds submit \ - --tag $(CR_LAUNCHPAD_IMAGE_URI) \ - --project=$(GCP_DEV_PROJECT_ID) - @echo " - Step 2: Deploying to Cloud Run..." - @gcloud run deploy $(CR_LAUNCHPAD_SERVICE_NAME) \ - --image $(CR_LAUNCHPAD_IMAGE_URI) \ - --platform managed \ - --region $(CR_LAUNCHPAD_REGION) \ - --no-allow-unauthenticated \ - --project=$(GCP_DEV_PROJECT_ID) - @echo " - Step 3: Enabling IAP on the service..." - @gcloud beta run services update $(CR_LAUNCHPAD_SERVICE_NAME) \ - --region=$(CR_LAUNCHPAD_REGION) \ - --project=$(GCP_DEV_PROJECT_ID) \ - --iap - @echo "--> ✅ Deployment to Cloud Run successful." +launchpad-dev: + @echo "--> Starting local Launchpad server using Firebase Hosting emulator..." + @echo " - Generating secure email hashes..." + @node scripts/generate-allowed-hashes.js + @firebase serve --only hosting:launchpad --project=$(FIREBASE_ALIAS) -deploy-launchpad-full: deploy-launchpad configure-iap-launchpad - @echo "✅ Launchpad deployed and IAP configured successfully!" +# --- Deployment --- +deploy-launchpad-hosting: + @echo "--> Deploying Internal Launchpad to Firebase Hosting..." + @echo " - Generating secure email hashes..." + @node scripts/generate-allowed-hashes.js + @echo " - Target: hosting:launchpad" + @echo " - Project: $(FIREBASE_ALIAS)" + @firebase deploy --only hosting:launchpad --project=$(FIREBASE_ALIAS) + @echo "--> ✅ Deployment to Firebase Hosting successful." deploy-app: build @echo "--> Deploying Frontend Web App to [$(ENV)] environment..." @@ -214,30 +203,6 @@ free-dev: dataconnect-sync @cd frontend-web-free && npm run dev -- --port 5174 # --- Cloud IAP Configuration --- -configure-iap-launchpad: - @echo "--> Configuring IAP for Cloud Run service [$(CR_LAUNCHPAD_SERVICE_NAME)]..." - @echo " - Granting Cloud Run Invoker role to IAP Service Account..." - @gcloud run services add-iam-policy-binding $(CR_LAUNCHPAD_SERVICE_NAME) \ - --region=$(CR_LAUNCHPAD_REGION) \ - --project=$(GCP_DEV_PROJECT_ID) \ - --member=\"serviceAccount:$(IAP_SERVICE_ACCOUNT)\" \ - --role='roles/run.invoker' \ - --quiet - @echo " - Adding users from iap-users.txt..." - @cd firebase/internal-launchpad && \ - grep -v '^#' iap-users.txt | grep -v '^$$' | while read -r member; do \ - echo " Adding $$member as IAP-secured Web App User..."; \ - gcloud beta iap web add-iam-policy-binding \ - --project=$(GCP_DEV_PROJECT_ID) \ - --resource-type=cloud-run \ - --service=$(CR_LAUNCHPAD_SERVICE_NAME) \ - --region=$(CR_LAUNCHPAD_REGION) \ - --member=\"$$member\" \ - --role='roles/iap.httpsResourceAccessor' \ - --quiet; \ - done - @echo "✅ IAP configuration for Launchpad complete." - configure-iap-admin: @echo "--> Configuring IAP for Cloud Run service [$(CR_ADMIN_SERVICE_NAME)] in [$(ENV)]..." @echo " - Granting Cloud Run Invoker role to IAP Service Account..." diff --git a/firebase.json b/firebase.json index 8900d6b8..88dc5410 100644 --- a/firebase.json +++ b/firebase.json @@ -11,6 +11,7 @@ "public": "firebase/internal-launchpad", "ignore": [ "firebase.json", + "iap-users.txt", "**/.*", "**/node_modules/**" ] @@ -48,7 +49,6 @@ { "target": "api-harness-dev", "public": "internal-api-harness/dist", - "site": "krow-api-harness-dev", "ignore": [ "firebase.json", "**/.*", @@ -64,7 +64,6 @@ { "target": "api-harness-staging", "public": "internal-api-harness/dist", - "site": "krow-api-harness-staging", "ignore": [ "firebase.json", "**/.*", diff --git a/firebase/internal-launchpad/.gcloudignore b/firebase/internal-launchpad/.gcloudignore deleted file mode 100644 index 28b93809..00000000 --- a/firebase/internal-launchpad/.gcloudignore +++ /dev/null @@ -1,18 +0,0 @@ -# This file specifies files that are *not* uploaded to Google Cloud -# using gcloud. It follows the same syntax as .gitignore, with the addition of -# "#!include" directives (which insert the entries of the given .gitignore-style -# file at that point). -# -# For more information, run: -# $ gcloud topic gcloudignore -# -.gcloudignore -# If you would like to upload your .git directory, .gitignore file or files -# from your .gitignore file, remove the corresponding line -# below: -.git -.gitignore - -# Node.js dependencies: -node_modules/ -*.log \ No newline at end of file diff --git a/firebase/internal-launchpad/Dockerfile b/firebase/internal-launchpad/Dockerfile deleted file mode 100644 index 84bf1d83..00000000 --- a/firebase/internal-launchpad/Dockerfile +++ /dev/null @@ -1,28 +0,0 @@ -# Utiliser nginx pour servir les fichiers statiques -FROM nginx:alpine - -# Copier les fichiers statiques -COPY index.html /usr/share/nginx/html/ -COPY assets /usr/share/nginx/html/assets/ -COPY favicon.svg /usr/share/nginx/html/ -COPY logo.svg /usr/share/nginx/html/ - -# Configuration nginx pour le routing SPA -RUN echo 'server { \ - listen 8080; \ - server_name _; \ - root /usr/share/nginx/html; \ - index index.html; \ - location / { \ - try_files $uri $uri/ /index.html; \ - } \ - # Headers de sécurité \ - add_header X-Frame-Options "SAMEORIGIN" always; \ - add_header X-Content-Type-Options "nosniff" always; \ - add_header X-XSS-Protection "1; mode=block" always; \ -}' > /etc/nginx/conf.d/default.conf - -# Nginx écoute sur le port 8080 (requis par Cloud Run) -EXPOSE 8080 - -CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file diff --git a/firebase/internal-launchpad/allowed-hashes.json b/firebase/internal-launchpad/allowed-hashes.json new file mode 100644 index 00000000..a3f1512d --- /dev/null +++ b/firebase/internal-launchpad/allowed-hashes.json @@ -0,0 +1,5 @@ +[ + "1b2e22bdec8f6493bf71ee535b6db6b4b5cd2d373f0ffb25524e229f3b5b7f5f", + "e075ff357ef35be2d55b0e383d59c5256980c492ada7ab84c84b2bb5ac26a73f", + "994b31c1aef3d59fe59bc3b8e1dec860a6fb3c73cbf41bdf45028e2c1ecbcf7a" +] \ No newline at end of file diff --git a/firebase/internal-launchpad/iap-users.txt b/firebase/internal-launchpad/iap-users.txt index 4b166559..a9e897ef 100644 --- a/firebase/internal-launchpad/iap-users.txt +++ b/firebase/internal-launchpad/iap-users.txt @@ -1,9 +1,14 @@ -# List of authorized users for the Internal Launchpad +# List of authorized users for the Krow DevOps Launchpad # Format: one email per line, lines starting with # are comments # -# IMPORTANT: These users must belong to the 'krowwithus.com' organization. -# This is a known limitation of enabling IAP directly on Cloud Run. -# See: https://docs.cloud.google.com/run/docs/securing/identity-aware-proxy-cloud-run#known_limitations +# Users must be listed here to access the Launchpad via Firebase Auth. +# Both internal (@krowwithus.com) and external emails are supported. user:admin@krowwithus.com -# user:boris@oloodi.com # External users are not supported with this IAP method + +# External users - Oloodi employees +user:boris@oloodi.com +user:achintha.isuru@oloodi.com + +# External users - Legendary employees + diff --git a/firebase/internal-launchpad/index.html b/firebase/internal-launchpad/index.html index 5857dfd4..472f97d7 100644 --- a/firebase/internal-launchpad/index.html +++ b/firebase/internal-launchpad/index.html @@ -4,7 +4,7 @@
-Verifying access...
+Please sign in to access internal development resources.
+ + + +Launchpad
+Launchpad Hub
Your central hub for workforce management infrastructure
+Central hub for KROW development and operations infrastructure