Skip to content

feat(policy): authorize authenticated principals - #85

Open
P4ST4S wants to merge 2 commits into
feat/principal-auth-abstractionfrom
feat/principal-aware-policy
Open

feat(policy): authorize authenticated principals#85
P4ST4S wants to merge 2 commits into
feat/principal-auth-abstractionfrom
feat/principal-aware-policy

Conversation

@P4ST4S

@P4ST4S P4ST4S commented Aug 24, 2026

Copy link
Copy Markdown
Owner

Summary

Étend le moteur de policy aux identités authentifiées et conserve une projection minimale du principal dans chaque événement d’audit concerné.

Context

Cette PR dépend de #83 pour Principal/Auth et de #81 pour les primitives d’opération MCP. Le commit de #81 est présent sur cette branche d’intégration ; il disparaîtra du diff lorsque la dépendance sera fusionnée.

Approach

  • ajoute les sélecteurs subject, issuer, role, scope, method et name ;
  • conserve intégralement les règles existantes client_id, server_id et tool_name ;
  • évalue roles et scopes par appartenance exacte, avec le wildcard historique ;
  • utilise le client_id authentifié pour la policy et le rate limiter HTTP ;
  • projette uniquement subject, client_id et issuer dans l’audit ;
  • persiste cette projection en JSONL et SQLite avec migration additive ;
  • garde un principal static explicite pour stdio et le mode local.

Test plan

  • go test -race ./... — passe
  • go build ./... — passe
  • go vet ./... — passe
  • matching complet subject/client/issuer/role/scope/method/name — couvert
  • absence de rôle ou scope requis — ne matche pas la règle
  • compatibilité des règles tool_name existantes — couverte
  • deny HTTP avant upstream avec identité authentifiée — couvert
  • projection d’audit et round-trip SQLite — couverts

Stability impact

Ajoute des sélecteurs optionnels à policy.rules et le champ audit principal. Les règles existantes gardent leur sémantique. Le principal audité ne contient jamais roles, scopes ni claims bruts.

Notes for reviewer

Le champ principal devra être inclus dans le payload Integrity v2 lors de l’intégration finale des branches d’audit ; la signature legacy reste volontairement inchangée conformément à STABILITY.md.

@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 84.89796% with 37 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/mcp/message.go 82.60% 4 Missing and 4 partials ⚠️
internal/mcp/headers.go 71.42% 3 Missing and 3 partials ⚠️
internal/mcp/metadata.go 92.00% 3 Missing and 3 partials ⚠️
internal/mcp/revision.go 82.35% 3 Missing and 3 partials ⚠️
internal/audit/storage/sqlite.go 75.00% 3 Missing and 2 partials ⚠️
internal/proxy/http.go 80.00% 2 Missing and 2 partials ⚠️
internal/proxy/stdio.go 85.71% 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