feat(portal): GhostAuth resource-server + bento widget endpoints - #50
Merged
Conversation
Makes GhostMonitor a first-class ghostboard portal app: it now serves a public
GhostApp manifest and two widget data_urls the portal renders, gated by GhostAuth
access tokens.
- core/security/resource_server.py: validates a GhostAuth access token (JWKS +
issuer + audience, RS256/ES256/EdDSA — mirrors ghostboard, EdDSA-capable via
joserfc). Discovery + JWKS cached.
- api/deps/portal.py: require_portal_token — extracts the bearer, verifies it,
requires the ghostsuite:ghostmon entitlement (scope ∪ groups), and maps the
token subject to the local user via oidc_subject (no JIT provisioning).
- api/routes/widgets.py: GET /api/v1/widgets/{uptime,latency} — per-user
services-up stat and recent-latency chart, in ghostboard's widget contract.
- /.well-known/ghostapp.yaml: public manifest (icon omitted so the portal keeps
its same-origin icon under its CSP). Cross-checked against ghostboard's loader:
validates, merges, data_urls + payloads accepted.
- OIDC_AUDIENCE setting (defaults to client id). Only these portal routes accept
GhostAuth tokens; the app's own UI/API keep local sessions.
Tests: 12 new (validator RS256/EdDSA + aud/iss/exp rejection; route token gate,
entitlement gate, per-user scoping, empty-on-unknown-subject, public manifest).
Full suite 247 pass, ruff + mypy strict clean.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Contexte
Pilote de l'intégration ghostboard pour la suite. GhostMonitor devient un app portail de premier plan : il publie un manifeste GhostApp et deux
data_urlque le portail rend, protégés par les access tokens GhostAuth (modèle resource-server léger validé avec l'équipe).Changements
core/security/resource_server.py— valide un token GhostAuth (JWKS +iss+aud, RS256/ES256/EdDSA). Calqué sur ghostboard ; EdDSA via joserfc (python-jose ne le supporte pas). Discovery + JWKS cachés.api/deps/portal.py—require_portal_token: extrait le bearer, le vérifie, exige l'entitlementghostsuite:ghostmon(scope ∪ groups), mappe lesubauUserlocal viaoidc_subject. Pas de JIT-provisioning (sub inconnu → widget vide → la tuile s'auto-masque).api/routes/widgets.py—GET /api/v1/widgets/{uptime,latency}: stat « services up » + chart latence récente, scopés à l'utilisateur, au format du contrat widget ghostboard./.well-known/ghostapp.yaml— manifeste public (iconomis pour que le portail garde son icône same-origin sous sa CSP).OIDC_AUDIENCE(défaut = client id). Seules ces routes portail acceptent un token GhostAuth ; l'UI/API de l'app gardent les sessions locales.Vérification (bout en bout, contrat)
Cross-check contre le vrai loader ghostboard : le manifeste valide, se merge (icon/auth épinglés au stub), les
data_urlcorrespondent au registry, et les payloads passentnormalize_widget_payload.Suite
Patron réutilisable → réplication sur ghostlink/ghostbit, et version « compteur only » pour les apps ZK (ghostcal/ghostmail/ghostpass).