-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add auto-event emission to CapiscioMiddleware #33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -10,6 +10,7 @@ | |||||||||||||
|
|
||||||||||||||
| from ..simple_guard import SimpleGuard | ||||||||||||||
| from ..errors import VerificationError | ||||||||||||||
| from ..events import EventEmitter | ||||||||||||||
| import time | ||||||||||||||
| import logging | ||||||||||||||
|
|
||||||||||||||
|
|
@@ -27,6 +28,9 @@ class CapiscioMiddleware(BaseHTTPMiddleware): | |||||||||||||
| guard: SimpleGuard instance for verification. | ||||||||||||||
| exclude_paths: List of paths to skip verification (e.g., ["/health", "/.well-known/agent-card.json"]). | ||||||||||||||
| config: Optional SecurityConfig to control enforcement behavior. | ||||||||||||||
| emitter: Optional EventEmitter for auto-event emission. When provided, | ||||||||||||||
| the middleware automatically emits request.received, request.completed, | ||||||||||||||
| verification.success, and verification.failed events. | ||||||||||||||
|
Comment on lines
+32
to
+33
|
||||||||||||||
| the middleware automatically emits request.received, request.completed, | |
| verification.success, and verification.failed events. | |
| the middleware automatically emits request.received, verification.success, | |
| and verification.failed events, and emits request.completed for requests | |
| that reach the downstream ASGI app (blocked 4xx responses may not emit | |
| request.completed). |
Copilot
AI
Feb 24, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the missing-badge branch for fail_mode = "log"/"monitor", the middleware currently emits request.received and request.completed but does not emit verification.failed. This conflicts with the PR description that verification.failed should be emitted when the badge is missing; consider emitting it here as well (without blocking).
Copilot
AI
Feb 24, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The verification.failed auto-event emitted for a blocked missing-badge request does not include duration_ms, but the PR description lists duration_ms as a key field for verification failures. Consider including a duration (e.g., from request_start).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EVENT_REQUEST_FAILEDis introduced but not referenced anywhere in the repository. If it’s not part of the current auto-event contract, consider removing it to avoid confusing API consumers, or wire it into the middleware and add coverage.