Author SHA1 Message Date
Sharang ParnerkarandClaude Opus 4.7 3fa0e26bd1 ci(portal): sign orca webhook POST with HMAC-SHA256
ci / shared (pull_request) Successful in 13s
ci / test (pull_request) Successful in 10m17s
ci / e2e (pull_request) Has been skipped
ci / image (pull_request) Has been skipped
When `orca webhooks add` registers a webhook it generates a signing
secret by default; orca then requires X-Hub-Signature-256 on inbound
POSTs (the public master at :6880 means anyone could otherwise fire
a deploy by crafting the JSON body).

Adds the signing step using the standard github-shaped header. The
secret is consumed from a new Gitea Actions secret ORCA_WEBHOOK_SECRET
on this repo — value provided out-of-band from the master.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-10 12:18:12 +02:00
Sharang ParnerkarandClaude Opus 4.7 8fc4dc09c9 ci(portal): retarget image build to registry.meghsakha.com + orca webhook
ci / shared (pull_request) Successful in 14s
ci / test (pull_request) Successful in 10m17s
ci / e2e (pull_request) Has been skipped
ci / image (pull_request) Has been skipped
The previous CI pushed to registry.breakpilot.com (the future prod
registry that doesn't exist yet) and tried to call `orca apply`, a
CLI shape this orca version doesn't ship. Repointing to the live
infrastructure:

- registry: registry.meghsakha.com
- image path: breakpilot/portal (sibling of breakpilot/compliance-*)
- tags: :latest (for the webhook-driven deploy) + :sha-<sha> (traceability)
- redeploy: POST github-style payload to the orca webhook on the master,
  matching the pattern documented in orca-infra/WEBHOOKS.md

The webhook must be registered once on the master:
  orca webhooks add --repo platform/portal \
                    --service breakpilot-portal --branch main

CI also needs REGISTRY_USER + REGISTRY_PASS set on this Gitea repo's
Actions secrets — same htpasswd-backed creds the master uses today.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-10 12:12:44 +02:00
8 changed files with 110 additions and 397 deletions
+5 -17
View File
@@ -8,10 +8,6 @@ on:
push:
branches: [main]
env:
COSIGN_KEY: ${{ secrets.COSIGN_KEY }}
COSIGN_PASSWORD: ${{ secrets.COSIGN_PASSWORD }}
jobs:
shared:
runs-on: docker
@@ -114,7 +110,7 @@ jobs:
image:
# Builds the portal image and ships it through the same path every
# other service in orca-infra uses: push :latest + :sha-<sha> to
# repo.breakpilot.com, then POST a github-style payload to the
# registry.meghsakha.com, then POST a github-style payload to the
# orca webhook so the master pulls and redeploys breakpilot-portal.
#
# Webhook target (registered once on the master via
@@ -122,29 +118,21 @@ jobs:
# --service breakpilot-portal --branch main
# ) accepts unsigned payloads — orca matches on repo + branch.
needs: [shared, test]
# NOTE: no hashFiles() here — at job level it evaluates BEFORE checkout
# against an empty workspace, so the old condition was always false and
# this job silently never ran (deployment sat on a June-10 image).
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && hashFiles('Dockerfile') != ''
runs-on: docker
steps:
- uses: actions/checkout@v4
- uses: docker/login-action@v3
with:
registry: repo.breakpilot.com
registry: registry.meghsakha.com
username: ${{ secrets.REGISTRY_USER }}
password: ${{ secrets.REGISTRY_PASS }}
- uses: docker/build-push-action@v6
with:
push: true
tags: |
repo.breakpilot.com/breakpilot/portal:latest
repo.breakpilot.com/breakpilot/portal:sha-${{ github.sha }}
- name: sign image (cosign)
run: |
{ command -v cosign >/dev/null 2>&1 || curl -sSfLo /usr/local/bin/cosign https://github.com/sigstore/cosign/releases/download/v2.4.3/cosign-linux-amd64 || wget -qO /usr/local/bin/cosign https://github.com/sigstore/cosign/releases/download/v2.4.3/cosign-linux-amd64; } || echo "::warning::cosign fetch failed"
chmod +x /usr/local/bin/cosign 2>/dev/null || true
cosign sign --yes --key env://COSIGN_KEY repo.breakpilot.com/breakpilot/portal:latest || echo "::warning::cosign failed"
registry.meghsakha.com/breakpilot/portal:latest
registry.meghsakha.com/breakpilot/portal:sha-${{ github.sha }}
- name: trigger orca redeploy
# Signs the POST with HMAC-SHA256 over the JSON body using the
# secret orca generated when the webhook was registered. Orca's
+4 -4
View File
@@ -22,7 +22,7 @@ jobs:
- name: verify stage soak (>= 24h on this image)
run: |
IMG=repo.breakpilot.com/breakpilot/${{ github.event.repository.name }}:env-stage
IMG=registry.breakpilot.com/${{ github.event.repository.name }}:env-stage
SOAK_SECONDS=$(orca image-age --env=stage --image $IMG)
if [ "$SOAK_SECONDS" -lt 86400 ]; then
echo "Stage soak only $SOAK_SECONDS s, < 24h. Aborting."
@@ -34,12 +34,12 @@ jobs:
- name: re-tag image as semver + env-prod
uses: docker/login-action@v3
with:
registry: repo.breakpilot.com
registry: registry.breakpilot.com
username: ${{ secrets.REGISTRY_USER }}
password: ${{ secrets.REGISTRY_PASS }}
- run: |
IMG=repo.breakpilot.com/breakpilot/${{ github.event.repository.name }}
IMG=registry.breakpilot.com/${{ github.event.repository.name }}
docker pull $IMG:env-stage
docker tag $IMG:env-stage $IMG:v${{ steps.v.outputs.version }}
docker tag $IMG:env-stage $IMG:env-prod
@@ -67,7 +67,7 @@ jobs:
curl -X POST -H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \
-H "Content-Type: application/json" \
-d "$(jq -Rs '{tag_name:"v${{ steps.v.outputs.version }}", name:"v${{ steps.v.outputs.version }}", body:.}' < RELEASE_NOTES.md)" \
https://git.breakpilot.com/api/v1/repos/${{ github.repository }}/releases
https://gitea.meghsakha.com/api/v1/repos/${{ github.repository }}/releases
rollback-on-failure:
needs: promote
+3 -10
View File
@@ -23,8 +23,8 @@
"clsx": "^2.1.1",
"geist": "^1.7.2",
"lucide-react": "^1.17.0",
"next": "16.2.11",
"next-auth": "5.0.0-beta.30",
"next": "16.2.6",
"next-auth": "5.0.0-beta.25",
"react": "19.0.0",
"react-dom": "19.0.0",
"tailwind-merge": "^3.6.0"
@@ -48,12 +48,5 @@
"workerDirectory": [
"public"
]
},
"pnpm": {
"overrides": {
"nanoid@<3.3.18": ">=3.3.18",
"postcss@<8.4.31": ">=8.4.31",
"@auth/core@<0.41.3": ">=0.41.3"
}
}
}
}
+96 -82
View File
@@ -4,11 +4,6 @@ settings:
autoInstallPeers: true
excludeLinksFromLockfile: false
overrides:
nanoid@<3.3.18: '>=3.3.18'
postcss@<8.4.31: '>=8.4.31'
'@auth/core@<0.41.3': '>=0.41.3'
importers:
.:
@@ -21,16 +16,16 @@ importers:
version: 2.1.1
geist:
specifier: ^1.7.2
version: 1.7.2(next@16.2.11(@babel/core@7.29.0)(@playwright/test@1.60.0)(react-dom@19.0.0(react@19.0.0))(react@19.0.0))
version: 1.7.2(next@16.2.6(@babel/core@7.29.0)(@playwright/test@1.60.0)(react-dom@19.0.0(react@19.0.0))(react@19.0.0))
lucide-react:
specifier: ^1.17.0
version: 1.17.0(react@19.0.0)
next:
specifier: 16.2.11
version: 16.2.11(@babel/core@7.29.0)(@playwright/test@1.60.0)(react-dom@19.0.0(react@19.0.0))(react@19.0.0)
specifier: 16.2.6
version: 16.2.6(@babel/core@7.29.0)(@playwright/test@1.60.0)(react-dom@19.0.0(react@19.0.0))(react@19.0.0)
next-auth:
specifier: 5.0.0-beta.30
version: 5.0.0-beta.30(next@16.2.11(@babel/core@7.29.0)(@playwright/test@1.60.0)(react-dom@19.0.0(react@19.0.0))(react@19.0.0))(react@19.0.0)
specifier: 5.0.0-beta.25
version: 5.0.0-beta.25(next@16.2.6(@babel/core@7.29.0)(@playwright/test@1.60.0)(react-dom@19.0.0(react@19.0.0))(react@19.0.0))(react@19.0.0)
react:
specifier: 19.0.0
version: 19.0.0
@@ -91,12 +86,12 @@ packages:
resolution: {integrity: sha512-30iZtAPgz+LTIYoeivqYo853f02jBYSd5uGnGpkFV0M3xOt9aN73erkgYAmZU43x4VfqcnLxW9Kpg3R5LC4YYw==}
engines: {node: '>=6.0.0'}
'@auth/core@0.41.3':
resolution: {integrity: sha512-sJ3JMHHkXMD3aOjopv7mOBTO1Ocw4b0fAEXJBz6k7YHLpYQI6C40jCUPc5fNvUKxXRXNE1/sRISA15UrwWJBTw==}
'@auth/core@0.37.2':
resolution: {integrity: sha512-kUvzyvkcd6h1vpeMAojK2y7+PAV5H+0Cc9+ZlKYDFhDY31AlvsB+GW5vNO4qE3Y07KeQgvNO9U0QUx/fN62kBw==}
peerDependencies:
'@simplewebauthn/browser': ^9.0.1
'@simplewebauthn/server': ^9.0.2
nodemailer: ^7.0.7 || ^8.0.5
nodemailer: ^6.8.0
peerDependenciesMeta:
'@simplewebauthn/browser':
optional: true
@@ -586,56 +581,56 @@ packages:
'@emnapi/core': ^1.7.1
'@emnapi/runtime': ^1.7.1
'@next/env@16.2.11':
resolution: {integrity: sha512-0do5A3BJ2gxWr0ZCMcD6BhW+e595jyxdTl3rXTS6lOtD8ektMiW6CO+EPwt1Eca1DBnm90r/7GdiKWBKxH++DA==}
'@next/env@16.2.6':
resolution: {integrity: sha512-gd8HoHN4ufj73WmR3JmVolrpJR47ILK6LouP5xElPglaVxir6e1a7VzvTvDWkOoPXT9rkkTzyCxBu4yeZfZwcw==}
'@next/eslint-plugin-next@16.2.6':
resolution: {integrity: sha512-Z8l6o4JWKUl755x4R+wogD86KPeU+Ckw4K+SYG4kHeOJtRenDeK+OSbGcqZpDtbwn9DsJVdir2UxmwXuinUbUw==}
'@next/swc-darwin-arm64@16.2.11':
resolution: {integrity: sha512-wryL4pjKmDwGv2ox6+GZDFxvmtSRLqApBR8kL1j4+vhB7Z5vJC/zAnXpiR9Xkfzl0AS8WLMnsuGV/UKI67/rrw==}
'@next/swc-darwin-arm64@16.2.6':
resolution: {integrity: sha512-ZJGkkcNfYgrrMkqOdZ7zoLa1TOy0qpcMfk/z4Mh/FKUz40gVO+HNQWqmLxf67Z5WB64DRp0dhEbyHfel+6sJUg==}
engines: {node: '>= 10'}
cpu: [arm64]
os: [darwin]
'@next/swc-darwin-x64@16.2.11':
resolution: {integrity: sha512-aZl2j4f/fLyjQvOhv0Oe9UaMAQHolYpKhctsoYzplSumKJKPUmgjcf6545aBtysLTcu994TREd0+pSgNE4ohmg==}
'@next/swc-darwin-x64@16.2.6':
resolution: {integrity: sha512-v/YLBHIY132Ced3puBJ7YJKw1lqsCrgcNo2aRJlCEyQrrCeRJlvGlnmxhPxNQI3KE3N1DN5r9TPNPvka3nq5RQ==}
engines: {node: '>= 10'}
cpu: [x64]
os: [darwin]
'@next/swc-linux-arm64-gnu@16.2.11':
resolution: {integrity: sha512-5jEriyEnH/LWFy27L2ZG0XaLlyEJIjhsImEsiS9P563PKEVp2BVups/xfOucIrsvVntp11oNcZwjHvaDPYVB5g==}
'@next/swc-linux-arm64-gnu@16.2.6':
resolution: {integrity: sha512-RPOvqlYBbcQjkz9VQQDZ2T2bARIjXZV1KFlt+V2Mr6SW/e4I9fcKsaA0hdyf2FHoTlsV2xnBd5Y912rP/1Ce6w==}
engines: {node: '>= 10'}
cpu: [arm64]
os: [linux]
'@next/swc-linux-arm64-musl@16.2.11':
resolution: {integrity: sha512-eIjcpx2fnnFSSkZDbTxy74KnokUXDjfoLClpWelfgHLf621aTqswhwXQ7GkD5K5rplrS6LZ/Bj+mVuvzluBOEg==}
'@next/swc-linux-arm64-musl@16.2.6':
resolution: {integrity: sha512-URUTu1+dMkxJsPFgm+OeEvq9wf5sujw0EvgYy80TDGHTSLTnIHeqb0Eu8A3sC95IRgjejQL+kC4mw+4yPxiAXA==}
engines: {node: '>= 10'}
cpu: [arm64]
os: [linux]
'@next/swc-linux-x64-gnu@16.2.11':
resolution: {integrity: sha512-8WgzpaWMs46qJT9kiV47cje86L0x/Mu9t8/Gwj+pnbgW3rETVfCnaScPjlYUwNScpOozdcIMHWmAvuZJUonR2w==}
'@next/swc-linux-x64-gnu@16.2.6':
resolution: {integrity: sha512-DOj182mPV8G3UkrayLoREM5YEYI+Dk5wv7Ox9xl1fFibAELEsFD0lDPfHIeILlutMMfdyhlzYPELG3peuKaurw==}
engines: {node: '>= 10'}
cpu: [x64]
os: [linux]
'@next/swc-linux-x64-musl@16.2.11':
resolution: {integrity: sha512-I3UgPds7G4ZYnTb/H+5GBGuUT2DhAk6j0mL6A4s63RjFs74wB2hOWP0vaxsK+3NJraExt3eYEPQ/UtT0x/64Nw==}
'@next/swc-linux-x64-musl@16.2.6':
resolution: {integrity: sha512-HKQ5SP/V/ub73UvF7n/zeJlxk2kLmtL7Wzrg4WfmkjmNos5onJ2tKu7yZOPdL18A6Svfn3max29ym+ry7NkK4g==}
engines: {node: '>= 10'}
cpu: [x64]
os: [linux]
'@next/swc-win32-arm64-msvc@16.2.11':
resolution: {integrity: sha512-n89CjtcThnjrwgJMAiI5xbqwLY51zvwC9tSlArmVndAJLYVl9T9UAdlkXTmZvE++idoXe8KdglQlhNRdUp1c6g==}
'@next/swc-win32-arm64-msvc@16.2.6':
resolution: {integrity: sha512-LZXpTlPyS5v7HhSmnvsLGP3iIYgYOBnc8r8ArlT55sGHV89bR2HlDdBjWQ+PY6SJMmk8TuVGFuxalnP3k/0Dwg==}
engines: {node: '>= 10'}
cpu: [arm64]
os: [win32]
'@next/swc-win32-x64-msvc@16.2.11':
resolution: {integrity: sha512-md8CLNggS1Dx9pUgApzps5uAf+N8GN9xywzmNx9vHAWo94HtBwCCqkSnhIrdfQe83Dhz8Lfo/20Nb1Zxal092w==}
'@next/swc-win32-x64-msvc@16.2.6':
resolution: {integrity: sha512-F0+4i0h9J6C4eE3EAPWsoCk7UW/dbzOjyzxY0qnDUOYFu6FFmdZ6l97/XdV3/Nz3VYyO7UWjyEJUXkGqcoXfMA==}
engines: {node: '>= 10'}
cpu: [x64]
os: [win32]
@@ -902,6 +897,9 @@ packages:
'@tybys/wasm-util@0.10.2':
resolution: {integrity: sha512-RoBvJ2X0wuKlWFIjrwffGw1IqZHKQqzIchKaadZZfnNpsAYp2mM0h36JtPCjNDAHGgYez/15uMBpfGwchhiMgg==}
'@types/cookie@0.6.0':
resolution: {integrity: sha512-4Kh9a6B2bQciAhf7FSuMRRkUWecJgJu9nPnx3yzpsfXX/c50REIqpHY4C82bXP90qrLtXtkDxTZosYO3UpOwlA==}
'@types/estree@1.0.8':
resolution: {integrity: sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==}
@@ -1317,6 +1315,10 @@ packages:
convert-source-map@2.0.0:
resolution: {integrity: sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==}
cookie@0.7.1:
resolution: {integrity: sha512-6DnInpx7SJ2AK3+CTUE/ZM0vWTUboZCegxhC2xiIydHR9jNuTAASBrfEpHhiGOZw/nX51bHt6YQl8jsGo4y/0w==}
engines: {node: '>= 0.6'}
cookie@1.1.1:
resolution: {integrity: sha512-ei8Aos7ja0weRpFzJnEA9UHJ/7XQmqglbRwnf2ATjcB9Wq874VKH9kfjjirM6UhU2/E5fFYadylyhFldcqSidQ==}
engines: {node: '>=18'}
@@ -1929,8 +1931,8 @@ packages:
resolution: {integrity: sha512-AC/7JofJvZGrrneWNaEnJeOLUx+JlGt7tNa0wZiRPT4MY1wmfKjt2+6O2p2uz2+skll8OZZmJMNqeke7kKbNgQ==}
hasBin: true
jose@6.2.10:
resolution: {integrity: sha512-iiW7J9qRFlGxvCOIBDBDxFePQSn7ZMAnrYGhrrOo6siO/MIqwfyilLR27pkfDgUk+raLuzADS8A3S/KLBisc0g==}
jose@5.10.0:
resolution: {integrity: sha512-s+3Al/p9g32Iq+oqXxkW//7jk2Vig6FF1CFqzVXoTUXt2qz89YWbL+OwS17NFYEvxC35n0FKeGO2LGYSxeM2Gg==}
js-tokens@4.0.0:
resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==}
@@ -2132,9 +2134,9 @@ packages:
resolution: {integrity: sha512-dkEJPVvun4FryqBmZ5KhDo0K9iDXAwn08tMLDinNdRBNPcYEDiWYysLcc6k3mjTMlbP9KyylvRpd4wFtwrT9rw==}
engines: {node: ^20.17.0 || >=22.9.0}
nanoid@6.0.1:
resolution: {integrity: sha512-3wVS3i51pE2pi1k5FFL/95BGfVS0kSsvDVuGXHOtxox/TywUmtgq+3qiTOTbs9J7KfHaXPiN171k/A6dBnaXFw==}
engines: {node: ^22 || ^24 || >=26}
nanoid@3.3.12:
resolution: {integrity: sha512-ZB9RH/39qpq5Vu6Y+NmUaFhQR6pp+M2Xt76XBnEwDaGcVAqhlvxrl3B2bKS5D3NH3QR76v3aSrKaF/Kiy7lEtQ==}
engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1}
hasBin: true
napi-postinstall@0.3.4:
@@ -2145,14 +2147,14 @@ packages:
natural-compare@1.4.0:
resolution: {integrity: sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==}
next-auth@5.0.0-beta.30:
resolution: {integrity: sha512-+c51gquM3F6nMVmoAusRJ7RIoY0K4Ts9HCCwyy/BRoe4mp3msZpOzYMyb5LAYc1wSo74PMQkGDcaghIO7W6Xjg==}
next-auth@5.0.0-beta.25:
resolution: {integrity: sha512-2dJJw1sHQl2qxCrRk+KTQbeH+izFbGFPuJj5eGgBZFYyiYYtvlrBeUw1E/OJJxTRjuxbSYGnCTkUIRsIIW0bog==}
peerDependencies:
'@simplewebauthn/browser': ^9.0.1
'@simplewebauthn/server': ^9.0.2
next: ^14.0.0-0 || ^15.0.0 || ^16.0.0
nodemailer: ^7.0.7
react: ^18.2.0 || ^19.0.0
next: ^14.0.0-0 || ^15.0.0-0
nodemailer: ^6.6.5
react: ^18.2.0 || ^19.0.0-0
peerDependenciesMeta:
'@simplewebauthn/browser':
optional: true
@@ -2161,8 +2163,8 @@ packages:
nodemailer:
optional: true
next@16.2.11:
resolution: {integrity: sha512-B339zaqbyK8cmxhoAvLrcwoabwCP1wz21zSzfqxqXAemTu2BXnH7tQnfcglKv1vnMUIDBc+Hth7XODQriTZiRQ==}
next@16.2.6:
resolution: {integrity: sha512-qOVgKJg1+At15NpeUP+eJgCHvTCgXsogweq87Ri/Ix7PkqQHg4sdaXmSFqKlgaIXE4kW0g25LE68W87UANlHtw==}
engines: {node: '>=20.9.0'}
hasBin: true
peerDependencies:
@@ -2308,18 +2310,21 @@ packages:
resolution: {integrity: sha512-FfR8sjd4em2T6fb3I2MwAJU7HWVMr9zba+enmQeeWFfCbm+UOC/0X4DS8XtpUTMwWMGbjKYP7xjfNekzyGmB3A==}
engines: {node: ^10 || ^12 || >=14}
preact-render-to-string@6.5.11:
resolution: {integrity: sha512-ubnauqoGczeGISiOh6RjX0/cdaF8v/oDXIjO85XALCQjwQP+SB4RDXXtvZ6yTYSjG+PC1QRP2AhPgCEsM2EvUw==}
preact-render-to-string@5.2.3:
resolution: {integrity: sha512-aPDxUn5o3GhWdtJtW0svRC2SS/l8D9MAgo2+AWml+BhDImb27ALf04Q2d+AHqUUOc6RdSXFIBVa2gxzgMKgtZA==}
peerDependencies:
preact: '>=10'
preact@10.24.3:
resolution: {integrity: sha512-Z2dPnBnMUfyQfSQ+GBdsGa16hz35YmLmtTLhM169uW944hYL6xzTYkJjC07j+Wosz733pMWx0fgON3JNw1jJQA==}
preact@10.11.3:
resolution: {integrity: sha512-eY93IVpod/zG3uMF22Unl8h9KkrcKIRs2EGar8hwLZZDU1lkjph303V9HZBwufh2s736U6VXuhD109LYqPoffg==}
prelude-ls@1.2.1:
resolution: {integrity: sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==}
engines: {node: '>= 0.8.0'}
pretty-format@3.8.0:
resolution: {integrity: sha512-WuxUnVtlWL1OfZFQFuqvnvs6MiAGk9UNsBostyBOB0Is9wb5uRESevA6rnl/rkksXaGX3GzZhPup5d6Vp1nFew==}
prop-types@15.8.1:
resolution: {integrity: sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==}
@@ -2808,13 +2813,15 @@ snapshots:
'@jridgewell/gen-mapping': 0.3.13
'@jridgewell/trace-mapping': 0.3.31
'@auth/core@0.41.3':
'@auth/core@0.37.2':
dependencies:
'@panva/hkdf': 1.2.1
jose: 6.2.10
'@types/cookie': 0.6.0
cookie: 0.7.1
jose: 5.10.0
oauth4webapi: 3.8.6
preact: 10.24.3
preact-render-to-string: 6.5.11(preact@10.24.3)
preact: 10.11.3
preact-render-to-string: 5.2.3(preact@10.11.3)
'@babel/code-frame@7.29.0':
dependencies:
@@ -3235,34 +3242,34 @@ snapshots:
'@tybys/wasm-util': 0.10.2
optional: true
'@next/env@16.2.11': {}
'@next/env@16.2.6': {}
'@next/eslint-plugin-next@16.2.6':
dependencies:
fast-glob: 3.3.1
'@next/swc-darwin-arm64@16.2.11':
'@next/swc-darwin-arm64@16.2.6':
optional: true
'@next/swc-darwin-x64@16.2.11':
'@next/swc-darwin-x64@16.2.6':
optional: true
'@next/swc-linux-arm64-gnu@16.2.11':
'@next/swc-linux-arm64-gnu@16.2.6':
optional: true
'@next/swc-linux-arm64-musl@16.2.11':
'@next/swc-linux-arm64-musl@16.2.6':
optional: true
'@next/swc-linux-x64-gnu@16.2.11':
'@next/swc-linux-x64-gnu@16.2.6':
optional: true
'@next/swc-linux-x64-musl@16.2.11':
'@next/swc-linux-x64-musl@16.2.6':
optional: true
'@next/swc-win32-arm64-msvc@16.2.11':
'@next/swc-win32-arm64-msvc@16.2.6':
optional: true
'@next/swc-win32-x64-msvc@16.2.11':
'@next/swc-win32-x64-msvc@16.2.6':
optional: true
'@nodelib/fs.scandir@2.1.5':
@@ -3454,6 +3461,8 @@ snapshots:
tslib: 2.8.1
optional: true
'@types/cookie@0.6.0': {}
'@types/estree@1.0.8': {}
'@types/estree@1.0.9': {}
@@ -3901,6 +3910,8 @@ snapshots:
convert-source-map@2.0.0: {}
cookie@0.7.1: {}
cookie@1.1.1: {}
cross-spawn@7.0.6:
@@ -4404,9 +4415,9 @@ snapshots:
functions-have-names@1.2.3: {}
geist@1.7.2(next@16.2.11(@babel/core@7.29.0)(@playwright/test@1.60.0)(react-dom@19.0.0(react@19.0.0))(react@19.0.0)):
geist@1.7.2(next@16.2.6(@babel/core@7.29.0)(@playwright/test@1.60.0)(react-dom@19.0.0(react@19.0.0))(react@19.0.0)):
dependencies:
next: 16.2.11(@babel/core@7.29.0)(@playwright/test@1.60.0)(react-dom@19.0.0(react@19.0.0))(react@19.0.0)
next: 16.2.6(@babel/core@7.29.0)(@playwright/test@1.60.0)(react-dom@19.0.0(react@19.0.0))(react@19.0.0)
generator-function@2.0.1: {}
@@ -4684,7 +4695,7 @@ snapshots:
jiti@2.7.0: {}
jose@6.2.10: {}
jose@5.10.0: {}
js-tokens@4.0.0: {}
@@ -4867,21 +4878,21 @@ snapshots:
mute-stream@3.0.0: {}
nanoid@6.0.1: {}
nanoid@3.3.12: {}
napi-postinstall@0.3.4: {}
natural-compare@1.4.0: {}
next-auth@5.0.0-beta.30(next@16.2.11(@babel/core@7.29.0)(@playwright/test@1.60.0)(react-dom@19.0.0(react@19.0.0))(react@19.0.0))(react@19.0.0):
next-auth@5.0.0-beta.25(next@16.2.6(@babel/core@7.29.0)(@playwright/test@1.60.0)(react-dom@19.0.0(react@19.0.0))(react@19.0.0))(react@19.0.0):
dependencies:
'@auth/core': 0.41.3
next: 16.2.11(@babel/core@7.29.0)(@playwright/test@1.60.0)(react-dom@19.0.0(react@19.0.0))(react@19.0.0)
'@auth/core': 0.37.2
next: 16.2.6(@babel/core@7.29.0)(@playwright/test@1.60.0)(react-dom@19.0.0(react@19.0.0))(react@19.0.0)
react: 19.0.0
next@16.2.11(@babel/core@7.29.0)(@playwright/test@1.60.0)(react-dom@19.0.0(react@19.0.0))(react@19.0.0):
next@16.2.6(@babel/core@7.29.0)(@playwright/test@1.60.0)(react-dom@19.0.0(react@19.0.0))(react@19.0.0):
dependencies:
'@next/env': 16.2.11
'@next/env': 16.2.6
'@swc/helpers': 0.5.15
baseline-browser-mapping: 2.10.31
caniuse-lite: 1.0.30001793
@@ -4890,14 +4901,14 @@ snapshots:
react-dom: 19.0.0(react@19.0.0)
styled-jsx: 5.1.6(@babel/core@7.29.0)(react@19.0.0)
optionalDependencies:
'@next/swc-darwin-arm64': 16.2.11
'@next/swc-darwin-x64': 16.2.11
'@next/swc-linux-arm64-gnu': 16.2.11
'@next/swc-linux-arm64-musl': 16.2.11
'@next/swc-linux-x64-gnu': 16.2.11
'@next/swc-linux-x64-musl': 16.2.11
'@next/swc-win32-arm64-msvc': 16.2.11
'@next/swc-win32-x64-msvc': 16.2.11
'@next/swc-darwin-arm64': 16.2.6
'@next/swc-darwin-x64': 16.2.6
'@next/swc-linux-arm64-gnu': 16.2.6
'@next/swc-linux-arm64-musl': 16.2.6
'@next/swc-linux-x64-gnu': 16.2.6
'@next/swc-linux-x64-musl': 16.2.6
'@next/swc-win32-arm64-msvc': 16.2.6
'@next/swc-win32-x64-msvc': 16.2.6
'@playwright/test': 1.60.0
sharp: 0.34.5
transitivePeerDependencies:
@@ -5023,24 +5034,27 @@ snapshots:
postcss@8.4.31:
dependencies:
nanoid: 6.0.1
nanoid: 3.3.12
picocolors: 1.1.1
source-map-js: 1.2.1
postcss@8.5.15:
dependencies:
nanoid: 6.0.1
nanoid: 3.3.12
picocolors: 1.1.1
source-map-js: 1.2.1
preact-render-to-string@6.5.11(preact@10.24.3):
preact-render-to-string@5.2.3(preact@10.11.3):
dependencies:
preact: 10.24.3
preact: 10.11.3
pretty-format: 3.8.0
preact@10.24.3: {}
preact@10.11.3: {}
prelude-ls@1.2.1: {}
pretty-format@3.8.0: {}
prop-types@15.8.1:
dependencies:
loose-envify: 1.4.0
+1 -14
View File
@@ -11,20 +11,7 @@ export type HostMatch =
| { kind: "unknown" };
// Longest-first so `stage.breakpilot.com` is matched before `breakpilot.com`.
// Built-ins cover dev (localhost) + the canonical breakpilot.com targets.
// PORTAL_APEX_HOSTS is a comma-separated env override for per-environment
// hosts (e.g. portal-dev.meghsakha.com while breakpilot.com isn't registered).
const APEX_HOSTS = (() => {
const base = ["stage.breakpilot.com", "breakpilot.com", "localhost"];
const extra = (process.env.PORTAL_APEX_HOSTS ?? "")
.split(",")
.map((h) => h.trim().toLowerCase())
.filter(Boolean);
// Longest-first to keep the suffix-strip loop correct.
return Array.from(new Set([...extra, ...base])).sort(
(a, b) => b.length - a.length,
);
})();
const APEX_HOSTS = ["stage.breakpilot.com", "breakpilot.com", "localhost"];
const APEX_SET = new Set(APEX_HOSTS);
export function parseHost(host: string | null | undefined): HostMatch {
-168
View File
@@ -1,168 +0,0 @@
import { afterEach, beforeEach, describe, expect, test, vi } from "vitest";
import {
resetServiceTokenCache,
serviceAuthHeader,
serviceToken,
} from "./service-token";
const ISSUER = "https://auth.breakpilot.com/realms/breakpilot-dev";
function tokenResponse(value: string, expiresIn = 300) {
return {
ok: true,
status: 200,
json: async () => ({ access_token: value, expires_in: expiresIn }),
} as Response;
}
function configure() {
process.env.KEYCLOAK_ISSUER = ISSUER;
process.env.PORTAL_SVC_CLIENT_ID = "portal-svc";
process.env.PORTAL_SVC_CLIENT_SECRET = "shh";
}
beforeEach(() => {
resetServiceTokenCache();
delete process.env.PORTAL_SVC_CLIENT_ID;
delete process.env.PORTAL_SVC_CLIENT_SECRET;
delete process.env.KEYCLOAK_ISSUER;
});
afterEach(() => {
vi.restoreAllMocks();
vi.useRealTimers();
});
describe("serviceToken", () => {
test("returns null and makes no request when unconfigured", async () => {
const fetchSpy = vi.spyOn(globalThis, "fetch");
expect(await serviceToken()).toBeNull();
expect(await serviceAuthHeader()).toEqual({});
expect(fetchSpy).not.toHaveBeenCalled();
});
test("requests a client_credentials token against the realm", async () => {
configure();
const fetchSpy = vi
.spyOn(globalThis, "fetch")
.mockResolvedValue(tokenResponse("tok-1"));
expect(await serviceToken()).toBe("tok-1");
const [url, init] = fetchSpy.mock.calls[0] as [string, RequestInit];
expect(url).toBe(`${ISSUER}/protocol/openid-connect/token`);
expect(init.method).toBe("POST");
const body = new URLSearchParams(init.body as string);
expect(body.get("grant_type")).toBe("client_credentials");
expect(body.get("client_id")).toBe("portal-svc");
expect(body.get("client_secret")).toBe("shh");
});
test("caches the token across calls", async () => {
configure();
const fetchSpy = vi
.spyOn(globalThis, "fetch")
.mockResolvedValue(tokenResponse("tok-1"));
await serviceToken();
await serviceToken();
await serviceToken();
expect(fetchSpy).toHaveBeenCalledTimes(1);
});
test("de-dupes concurrent fetches into one request", async () => {
configure();
const fetchSpy = vi
.spyOn(globalThis, "fetch")
.mockResolvedValue(tokenResponse("tok-1"));
const results = await Promise.all([
serviceToken(),
serviceToken(),
serviceToken(),
]);
expect(results).toEqual(["tok-1", "tok-1", "tok-1"]);
expect(fetchSpy).toHaveBeenCalledTimes(1);
});
test("refreshes shortly before expiry", async () => {
configure();
vi.useFakeTimers();
vi.setSystemTime(new Date("2026-08-25T10:00:00Z"));
const fetchSpy = vi
.spyOn(globalThis, "fetch")
.mockResolvedValueOnce(tokenResponse("tok-1", 300))
.mockResolvedValueOnce(tokenResponse("tok-2", 300));
expect(await serviceToken()).toBe("tok-1");
// 4 minutes in: still inside the window
vi.setSystemTime(new Date("2026-08-25T10:04:00Z"));
expect(await serviceToken()).toBe("tok-1");
// 4:40 — inside the 30s refresh margin
vi.setSystemTime(new Date("2026-08-25T10:04:40Z"));
expect(await serviceToken()).toBe("tok-2");
expect(fetchSpy).toHaveBeenCalledTimes(2);
});
test("surfaces a rejected token request instead of calling unauthenticated", async () => {
configure();
// no json() on the mock: fetchToken throws on !ok before reading the body
vi.spyOn(globalThis, "fetch").mockResolvedValue({
ok: false,
status: 401,
} as Response);
await expect(serviceToken()).rejects.toThrow("service token request failed: 401");
});
test("surfaces a malformed token response", async () => {
configure();
vi.spyOn(globalThis, "fetch").mockResolvedValue({
ok: true,
status: 200,
json: async () => ({}),
} as Response);
await expect(serviceToken()).rejects.toThrow("no access_token");
});
test("a failed fetch does not poison the cache", async () => {
configure();
vi.spyOn(globalThis, "fetch")
.mockResolvedValueOnce({ ok: false, status: 503 } as Response)
.mockResolvedValueOnce(tokenResponse("tok-ok"));
await expect(serviceToken()).rejects.toThrow();
expect(await serviceToken()).toBe("tok-ok");
});
test("a response without expires_in gets the 300s default lifetime", async () => {
configure();
vi.useFakeTimers();
vi.setSystemTime(new Date("2026-08-30T10:00:00Z"));
const fetchSpy = vi
.spyOn(globalThis, "fetch")
.mockResolvedValueOnce({
ok: true,
status: 200,
json: async () => ({ access_token: "tok-default" }),
} as Response)
.mockResolvedValueOnce(tokenResponse("tok-next"));
expect(await serviceToken()).toBe("tok-default");
// 4 minutes in: still inside the defaulted 300s window
vi.setSystemTime(new Date("2026-08-30T10:04:00Z"));
expect(await serviceToken()).toBe("tok-default");
// past the default expiry
vi.setSystemTime(new Date("2026-08-30T10:05:01Z"));
expect(await serviceToken()).toBe("tok-next");
expect(fetchSpy).toHaveBeenCalledTimes(2);
});
test("serviceAuthHeader carries the bearer token when configured", async () => {
configure();
vi.spyOn(globalThis, "fetch").mockResolvedValue(tokenResponse("tok-1"));
expect(await serviceAuthHeader()).toEqual({ authorization: "Bearer tok-1" });
});
});
-96
View File
@@ -1,96 +0,0 @@
// Client-credentials service token for portal → tenant-registry calls.
//
// tenant-registry's API is INTERNAL_SERVICE_ONLY: once its AUTH_ENABLED
// flips, every route except /healthz and /readyz needs a Keycloak token
// whose audience contains `tenant-registry`. The portal is a service
// principal here — this is machine-to-machine, unrelated to the visitor's
// SSO session (that one authenticates a human against `dev-portal`).
//
// Inert until configured: with no PORTAL_SVC_CLIENT_ID / _SECRET the
// helper returns null and callers send no Authorization header, which is
// exactly today's behaviour against a tenant-registry that is not yet
// enforcing. Configure both to switch the portal over.
//
// Server-only: the client secret must never reach the browser. Every
// caller (src/lib/tenant-registry.ts) already runs server-side.
const REFRESH_MARGIN_SECONDS = 30;
type CachedToken = { value: string; expiresAt: number };
let cached: CachedToken | null = null;
// de-dupes concurrent fetches: many parallel renders share one request
let inFlight: Promise<CachedToken> | null = null;
function config(): { issuer: string; clientId: string; secret: string } | null {
const clientId = process.env.PORTAL_SVC_CLIENT_ID;
const secret = process.env.PORTAL_SVC_CLIENT_SECRET;
const issuer = process.env.KEYCLOAK_ISSUER;
if (!clientId || !secret || !issuer) return null;
return { issuer, clientId, secret };
}
async function fetchToken(cfg: {
issuer: string;
clientId: string;
secret: string;
}): Promise<CachedToken> {
const res = await fetch(`${cfg.issuer}/protocol/openid-connect/token`, {
method: "POST",
headers: { "content-type": "application/x-www-form-urlencoded" },
body: new URLSearchParams({
grant_type: "client_credentials",
client_id: cfg.clientId,
client_secret: cfg.secret,
}),
cache: "no-store",
});
if (!res.ok) {
throw new Error(`service token request failed: ${res.status}`);
}
const body = (await res.json()) as {
access_token?: string;
expires_in?: number;
};
if (!body.access_token) {
throw new Error("service token response carried no access_token");
}
return {
value: body.access_token,
expiresAt: Date.now() / 1000 + (body.expires_in ?? 300),
};
}
/**
* A valid service token, or null when the portal is not configured to
* send one. Cached in memory and refreshed shortly before expiry (realm
* tokens live 5 minutes).
*/
export async function serviceToken(): Promise<string | null> {
const cfg = config();
if (!cfg) return null;
const now = Date.now() / 1000;
if (cached && now < cached.expiresAt - REFRESH_MARGIN_SECONDS) {
return cached.value;
}
if (!inFlight) {
inFlight = fetchToken(cfg).finally(() => {
inFlight = null;
});
}
cached = await inFlight;
return cached.value;
}
/** Authorization header for an outbound call, or {} when unconfigured. */
export async function serviceAuthHeader(): Promise<Record<string, string>> {
const token = await serviceToken();
return token ? { authorization: `Bearer ${token}` } : {};
}
/** Test seam: drop the cached token. */
export function resetServiceTokenCache(): void {
cached = null;
inFlight = null;
}
+1 -6
View File
@@ -1,8 +1,6 @@
// Tenant Registry client — covers everything the portal needs to call
// from server components and server actions.
import { serviceAuthHeader } from "./service-token";
export type Tenant = {
id: string;
slug: string;
@@ -76,12 +74,9 @@ async function req<T>(
path: string,
body?: unknown,
): Promise<{ status: number; data: T | null }> {
// tenant-registry is INTERNAL_SERVICE_ONLY — the portal calls it as a
// service principal. Unconfigured ⇒ {} ⇒ unchanged, header-less calls.
const auth = await serviceAuthHeader();
const init: RequestInit = {
method,
headers: { accept: "application/json", ...auth },
headers: { accept: "application/json" },
cache: "no-store",
};
if (body !== undefined) {