Skip to content

feat(auth): add HTTP security principals - #83

Open
P4ST4S wants to merge 1 commit into
feat/http-security-hardening-68from
feat/principal-auth-abstraction
Open

feat(auth): add HTTP security principals#83
P4ST4S wants to merge 1 commit into
feat/http-security-hardening-68from
feat/principal-auth-abstraction

Conversation

@P4ST4S

@P4ST4S P4ST4S commented Aug 23, 2026

Copy link
Copy Markdown
Owner

Summary

Introduit une identité de sécurité explicite pour chaque requête HTTP, un contrat d’authentification composable et deux modes initiaux : principal local compatible et bearer statique.

Context

Cette PR est empilée sur #79. Elle pose le socle de l’authentification JWT/OIDC et des policies principal-aware sans changer encore le moteur de policy.

Approach

  • ajoute Principal avec subject, client_id, issuer, roles, scopes et claims internes ;
  • propage le principal authentifié dans le contexte HTTP avec copies défensives ;
  • conserve le mode local via un principal statique explicitement configuré ;
  • ajoute un mode static_bearer avec token de 32 octets minimum, stocké uniquement sous forme d’empreinte SHA-256 et comparé en temps constant ;
  • rejette les credentials absents, invalides ou dupliqués avec 401 et WWW-Authenticate ;
  • ajoute MCP_AUDIT_STATIC_BEARER_TOKEN pour éviter de placer le secret dans le fichier ;
  • retire Authorization avant forwarding selon le comportement sécurisé existant.

Test plan

  • go test -race ./... — passe
  • go build ./... — passe
  • go vet ./... — passe
  • authentification absente, invalide, dupliquée et valide — couverte
  • propagation du principal et copies défensives imbriquées — couvertes
  • non-forwarding du bearer et métrique authentication — couverts
  • validation config et surcharge par variable d’environnement — couvertes

Stability impact

Ajoute auth.mode, auth.static.* et la raison de métrique authentication. Le défaut none préserve les usages locaux avec un principal statique ; aucune authentification réseau n’est activée implicitement.

Notes for reviewer

Les claims ne sont ni audités ni exposés. La projection d’audit minimale et l’utilisation par le moteur de policy sont réservées à la PR principal-aware.

@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 78.03030% with 29 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cmd/mcp-audit/main.go 78.00% 10 Missing and 1 partial ⚠️
internal/auth/auth.go 82.35% 4 Missing and 2 partials ⚠️
internal/proxy/http.go 73.91% 4 Missing and 2 partials ⚠️
internal/auth/static_bearer.go 78.94% 2 Missing and 2 partials ⚠️
internal/auth/none.go 66.66% 1 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

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