API Reference¶
Complete reference for all fastapi-topaz public exports.
Configuration¶
TopazConfig¶
Configuration for Topaz authorization. Create once at app startup, use to generate authorization dependencies.
| PARAMETER | DESCRIPTION |
|---|---|
authorizer_options
|
Connection settings for Topaz authorizer
TYPE:
|
policy_path_root
|
Root package name for policies (e.g., "myapp")
TYPE:
|
identity_provider
|
Function to extract user identity from request
TYPE:
|
policy_instance_name
|
Name of policy instance to evaluate
TYPE:
|
policy_instance_label
|
Label for policy instance (defaults to name)
TYPE:
|
resource_context_provider
|
Function to provide additional context
TYPE:
|
policy_path_normalizer
|
Optional callable to transform generated policy paths (e.g., replace hyphens with underscores for valid Rego identifiers)
TYPE:
|
default_policy
|
Optional fallback policy path evaluated when no explicit policy file exists and no policy group matches. All requests still go through Topaz — this only changes which policy is evaluated.
TYPE:
|
policy_groups
|
Optional ordered list of :class:
TYPE:
|
decision_cache
|
Optional cache for authorization decisions
TYPE:
|
max_concurrent_checks
|
Max concurrent authorization checks for bulk operations (default: 10)
TYPE:
|
circuit_breaker
|
Optional circuit breaker for graceful degradation
TYPE:
|
connection_pool
|
Optional connection pool for gRPC connection reuse
TYPE:
|
audit_logger
|
Optional audit logger for authorization decisions
TYPE:
|
metrics
|
Optional Prometheus metrics collector
TYPE:
|
tracing
|
Optional OpenTelemetry tracing
TYPE:
|
Source code in src/fastapi_topaz/config.py
check_decision
async
¶
check_decision(request: Request, policy_path: str, decision: str, resource_context: ResourceContext | None = None, source: str = 'dependency') -> bool
Check an authorization decision, using cache if available.
This is the core authorization check method that handles caching, circuit breaker logic, and can be used directly for custom authorization logic.
Source code in src/fastapi_topaz/config.py
268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 | |
is_allowed
async
¶
is_allowed(request: Request, policy_path: str, resource_context: ResourceContext | None = None, decision: str = 'allowed') -> bool
Check if an action is allowed without raising an exception.
This is a non-raising alternative to require_policy_allowed that returns True/False instead of raising HTTPException(403). Useful for UI patterns where you need to check permissions without blocking (e.g., showing/hiding edit or delete buttons).
| PARAMETER | DESCRIPTION |
|---|---|
request
|
The FastAPI request object
TYPE:
|
policy_path
|
Full policy path (e.g., "webapp.PUT.documents")
TYPE:
|
resource_context
|
Optional resource context dict
TYPE:
|
decision
|
Decision to check (default: "allowed")
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if allowed, False otherwise |
Example
Source code in src/fastapi_topaz/config.py
check_relation
async
¶
check_relation(request: Request, object_type: str, object_id: str, relation: str, subject_type: str = 'user') -> bool
Check a ReBAC relation without raising an exception.
This is a non-raising alternative to require_rebac_allowed that returns True/False instead of raising HTTPException(403). Useful for checking if a user has a specific relationship with an object.
| PARAMETER | DESCRIPTION |
|---|---|
request
|
The FastAPI request object
TYPE:
|
object_type
|
Type of object (e.g., "document", "folder")
TYPE:
|
object_id
|
ID of the object to check
TYPE:
|
relation
|
Relation to check (e.g., "can_read", "can_write", "can_delete")
TYPE:
|
subject_type
|
Subject type (default: "user")
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if the relation exists, False otherwise |
Example
Source code in src/fastapi_topaz/config.py
check_relations
async
¶
check_relations(request: Request, object_type: str, object_id: str, relations: list[str], subject_type: str = 'user') -> dict[str, bool]
Check multiple ReBAC relations at once without raising exceptions.
This method checks multiple relations concurrently and returns a dict mapping relation names to boolean results. Useful for fetching all permissions for an object in a single call (e.g., to populate a permissions object in an API response).
| PARAMETER | DESCRIPTION |
|---|---|
request
|
The FastAPI request object
TYPE:
|
object_type
|
Type of object (e.g., "document", "folder")
TYPE:
|
object_id
|
ID of the object to check
TYPE:
|
relations
|
List of relations to check (e.g., ["can_read", "can_write", "can_delete"])
TYPE:
|
subject_type
|
Subject type (default: "user")
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict[str, bool]
|
Dict mapping relation names to boolean results |
Example
@app.get("/documents/{id}")
async def get_document(id: int, request: Request):
doc = await fetch_document(id)
permissions = await config.check_relations(
request,
object_type="document",
object_id=str(id),
relations=["can_read", "can_write", "can_delete", "can_share"],
)
# permissions = {"can_read": True, "can_write": True, "can_delete": False, "can_share": False}
return {"document": doc, "permissions": permissions}
Source code in src/fastapi_topaz/config.py
policy_path_for ¶
Generate the policy path for a given HTTP method and route path.
Useful for debugging, testing, or previewing what policy path will be generated for a given route.
| PARAMETER | DESCRIPTION |
|---|---|
method
|
HTTP method (e.g., "GET", "POST")
TYPE:
|
route_path
|
URL path pattern (e.g., "/documents/{id}")
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
The policy path that would be used for authorization |
Example
config.policy_path_for("GET", "/documents/{id}") "myapp.GET.documents.__id"
Source code in src/fastapi_topaz/config.py
create_client ¶
Create a Topaz authorizer client with identity from request.
Source code in src/fastapi_topaz/config.py
DecisionCache¶
Simple in-memory TTL cache for authorization decisions.
| PARAMETER | DESCRIPTION |
|---|---|
ttl_seconds
|
Time-to-live for cache entries (default: 60 seconds)
TYPE:
|
max_size
|
Maximum number of entries to cache (default: 1000)
TYPE:
|
get
async
¶
get(identity_value: str, policy_path: str, decision: str, resource_context: ResourceContext | None) -> bool | None
Get a cached decision, or None if not cached or expired.
Source code in src/fastapi_topaz/cache.py
set
async
¶
set(identity_value: str, policy_path: str, decision: str, resource_context: ResourceContext | None, value: bool) -> None
Cache a decision.
Source code in src/fastapi_topaz/cache.py
Authorization Dependencies¶
require_policy_allowed¶
Async dependency that raises HTTPException(403) if policy denies access.
| PARAMETER | DESCRIPTION |
|---|---|
config
|
Topaz configuration
TYPE:
|
policy_path
|
Full policy path (e.g., "webapp.POST.api.documents")
TYPE:
|
decision
|
Decision to check (default: "allowed")
TYPE:
|
resource_context
|
Optional resource context dict
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Callable[[Request], Awaitable[None]]
|
Async dependency function for FastAPI |
Example
Source code in src/fastapi_topaz/dependencies.py
require_policy_auto¶
Async dependency that auto-generates policy path from route and raises HTTPException(403) if denied.
The policy path is automatically derived from the HTTP method and route path pattern: - GET /documents -> {root}.GET.documents - POST /documents -> {root}.POST.documents - GET /documents/{id} -> {root}.GET.documents.__id - PUT /users/{user_id}/docs/{doc_id} -> {root}.PUT.users.__user_id.docs.__doc_id
| PARAMETER | DESCRIPTION |
|---|---|
config
|
Topaz configuration
TYPE:
|
decision
|
Decision to check (default: "allowed")
TYPE:
|
resource_context
|
Optional resource context dict
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Callable[[Request], Awaitable[None]]
|
Async dependency function for FastAPI |
Example
Source code in src/fastapi_topaz/dependencies.py
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | |
require_rebac_allowed¶
Async dependency that raises HTTPException(403) if ReBAC check fails.
| PARAMETER | DESCRIPTION |
|---|---|
config
|
Topaz configuration
TYPE:
|
object_type
|
Type of object (e.g., "document", "folder")
TYPE:
|
relation
|
Relation to check (e.g., "can_write", "can_delete")
TYPE:
|
object_id
|
Static ID, callable to extract from request, or None (uses path param "id")
TYPE:
|
subject_type
|
Subject type (default: "user")
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Callable[[Request], Awaitable[None]]
|
Async dependency function for FastAPI |
Example
Source code in src/fastapi_topaz/dependencies.py
get_authorized_resource¶
Async dependency that fetches a resource and checks authorization. Returns resource or raises 403/404.
| PARAMETER | DESCRIPTION |
|---|---|
config
|
Topaz configuration
TYPE:
|
resource_fetcher
|
Function that takes (request) and returns resource or None
TYPE:
|
object_type
|
Type of object (e.g., "document")
TYPE:
|
relation
|
Relation to check (e.g., "can_write")
TYPE:
|
object_id
|
Static ID, callable, or None (uses path param "id")
TYPE:
|
subject_type
|
Subject type (default: "user")
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Callable[[Request], Awaitable[T]]
|
Async dependency function that returns the authorized resource |
Example
def fetch_document(request: Request, db: Session) -> Document | None:
doc_id = request.path_params["id"]
return db.query(Document).filter(Document.id == doc_id).first()
@router.put("/documents/{id}")
async def update_document(
document: Document = Depends(
get_authorized_resource(topaz_config, fetch_document, "document", "can_write")
),
):
# document is pre-fetched and authorized
...
Source code in src/fastapi_topaz/dependencies.py
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 | |
filter_authorized_resources¶
Async dependency that returns an async filter function to remove unauthorized resources.
Uses concurrent authorization checks (controlled by config.max_concurrent_checks) and caching (if config.decision_cache is set) for optimal performance.
| PARAMETER | DESCRIPTION |
|---|---|
config
|
Topaz configuration
TYPE:
|
object_type
|
Type of object (e.g., "document")
TYPE:
|
relation
|
Relation to check (e.g., "can_read")
TYPE:
|
id_extractor
|
Function to extract ID from resource object
TYPE:
|
subject_type
|
Subject type (default: "user")
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Callable[[Request], Awaitable[Callable[[list[T]], Awaitable[list[T]]]]]
|
Async dependency that returns an async filter function |
Example
Source code in src/fastapi_topaz/dependencies.py
require_rebac_hierarchy¶
Async dependency for hierarchical ReBAC authorization.
Checks multiple object/relation pairs in a single dependency, reducing boilerplate for nested resources like /orgs/{org}/projects/{proj}/docs/{doc}.
| PARAMETER | DESCRIPTION |
|---|---|
config
|
Topaz configuration
TYPE:
|
checks
|
List of (object_type, id_source, relation) tuples. id_source can be: - "param_name" -> request.path_params["param_name"] - "header:X-Name" -> request.headers["X-Name"] - "query:name" -> request.query_params["name"] - "static:value" -> literal "value" - callable -> callable(request)
TYPE:
|
mode
|
Check mode: - "all" (default): All checks must pass (AND). Fails fast. - "any": At least one check must pass (OR). - "first_match": Return on first success.
TYPE:
|
subject_type
|
Subject type (default: "user")
TYPE:
|
optimize
|
Run checks concurrently when possible (default: True)
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Callable[[Request], Awaitable[None]]
|
Async dependency function for FastAPI |
| RAISES | DESCRIPTION |
|---|---|
HTTPException(403)
|
If authorization fails based on mode semantics |
Example
Source code in src/fastapi_topaz/dependencies.py
HierarchyResult¶
Result of a hierarchy authorization check.
| ATTRIBUTE | DESCRIPTION |
|---|---|
allowed |
Whether the hierarchy check passed
TYPE:
|
checks |
List of (object_type, object_id, relation, result) tuples
TYPE:
|
denied_at |
Object type where access was denied (mode="all")
TYPE:
|
first_match |
Relation that matched first (mode="first_match")
TYPE:
|
as_dict ¶
Middleware¶
TopazMiddleware¶
FastAPI middleware for global authorization (pure ASGI).
Auto-protects all routes by checking policy paths derived from HTTP method and route pattern. Routes are protected unless explicitly excluded.
Policy Resolution Chain (first match wins):
1. Explicit: Route has a .rego file in policies_dir
2. Group: Route matches a :class:PolicyGroup url_pattern
3. Default: config.default_policy is set
4. Generated: Use auto-generated policy path (legacy behaviour)
| PARAMETER | DESCRIPTION |
|---|---|
app
|
The FastAPI application
TYPE:
|
config
|
TopazConfig with authorizer settings
TYPE:
|
exclude_paths
|
Regex patterns for paths to skip (e.g., [r"^/health$", r"^/docs.*"])
TYPE:
|
exclude_methods
|
HTTP methods to skip (default: ["OPTIONS", "HEAD"])
TYPE:
|
on_missing_identity
|
How to handle missing identity: - "deny": Return 401 Unauthorized - "anonymous": Pass anonymous identity to Topaz (let policy decide)
TYPE:
|
on_denied
|
Optional callback to customize 403 response
TYPE:
|
policies_dir
|
Optional directory to scan for explicit
TYPE:
|
Source code in src/fastapi_topaz/middleware.py
skip_middleware¶
Decorator to mark a route as excluded from authorization middleware.
The decorated endpoint will not be checked by TopazMiddleware, allowing you to implement custom authorization logic.
from fastapi_topaz import skip_middleware
@app.post("/documents/bulk-import")
@skip_middleware
async def bulk_import(
_=Depends(require_policy_allowed(config, "myapp.admin.bulk_import")),
):
# Custom policy path, not auto-generated
...
Source code in src/fastapi_topaz/middleware.py
SkipMiddleware¶
Marker dependency to skip authorization middleware for a router or route.
Use as a dependency on a router to exclude all routes from middleware authorization:
from fastapi import APIRouter, Depends
from fastapi_topaz import SkipMiddleware
public_router = APIRouter(
prefix="/api/public",
dependencies=[Depends(SkipMiddleware)],
)
@public_router.get("/status") # Automatically excluded from middleware
async def public_status():
return {"status": "ok"}
Circuit Breaker¶
CircuitBreaker¶
Circuit breaker configuration for Topaz authorization.
Prevents cascading failures when Topaz is unavailable by opening the circuit after a threshold of failures, using fallback strategies, and automatically testing for recovery.
| PARAMETER | DESCRIPTION |
|---|---|
failure_threshold
|
Number of consecutive failures before opening circuit
TYPE:
|
success_threshold
|
Number of successes in half-open before closing
TYPE:
|
recovery_timeout
|
Seconds to wait before transitioning to half-open
TYPE:
|
fallback
|
Strategy when circuit is open ("cache_then_deny", "cache_then_allow", "deny", "allow", or custom callable)
TYPE:
|
serve_stale_cache
|
Whether to serve expired cache entries when open
TYPE:
|
stale_cache_ttl
|
Maximum age (seconds) of stale cache to serve
TYPE:
|
failure_exceptions
|
Exception types that count as failures
TYPE:
|
timeout_ms
|
Consider timeout after this many milliseconds
TYPE:
|
on_state_change
|
Callback when circuit state changes
TYPE:
|
on_fallback
|
Callback when fallback is used
TYPE:
|
half_open_max_requests
|
Number of test requests allowed in half-open state
TYPE:
|
Example
status ¶
status() -> CircuitStatus
Get current circuit status for health checks.
Source code in src/fastapi_topaz/circuit_breaker.py
should_allow_request
async
¶
Check if a request should be allowed through to Topaz.
Returns True if the circuit is closed or if we should test in half-open. Returns False if the circuit is open and fallback should be used.
Source code in src/fastapi_topaz/circuit_breaker.py
record_success
async
¶
Record a successful authorization call.
Source code in src/fastapi_topaz/circuit_breaker.py
record_failure
async
¶
Record a failed authorization call.
Source code in src/fastapi_topaz/circuit_breaker.py
get_fallback_decision
async
¶
get_fallback_decision(request: Request, policy_path: str, resource_context: dict[str, Any], cached_decision: bool | None, error: Exception) -> bool
Get the fallback decision when circuit is open.
| PARAMETER | DESCRIPTION |
|---|---|
request
|
The FastAPI request
TYPE:
|
policy_path
|
The policy path being checked
TYPE:
|
resource_context
|
The resource context
TYPE:
|
cached_decision
|
Cached decision (may be stale), or None if not cached
TYPE:
|
error
|
The exception that caused the fallback
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Authorization decision (True/False) |
Source code in src/fastapi_topaz/circuit_breaker.py
reset
async
¶
Reset the circuit breaker to initial state.
Source code in src/fastapi_topaz/circuit_breaker.py
is_failure_exception ¶
Check if an exception should count as a circuit breaker failure.
CircuitState¶
CircuitStatus¶
Connection Pool¶
ConnectionPool¶
Async connection pool for AuthorizerClient connections.
Manages a pool of gRPC connections to Topaz, reusing them across requests to reduce connection overhead.
| PARAMETER | DESCRIPTION |
|---|---|
min_connections
|
Minimum connections to keep warm
TYPE:
|
max_connections
|
Maximum connections allowed
TYPE:
|
acquire_timeout
|
Seconds to wait for a connection
TYPE:
|
connection_timeout
|
Seconds to establish a new connection
TYPE:
|
max_idle_time
|
Seconds before closing idle connections
TYPE:
|
idle_check_interval
|
Seconds between idle cleanup runs
TYPE:
|
health_check_interval
|
Seconds between health checks
TYPE:
|
health_check_timeout
|
Seconds for health check to complete
TYPE:
|
eager_init
|
Create min_connections at initialization
TYPE:
|
retry_on_failure
|
Retry failed connection creation
TYPE:
|
max_retries
|
Maximum connection creation retries
TYPE:
|
configure ¶
Configure the pool with authorizer options.
initialize
async
¶
Initialize the pool, optionally creating min_connections.
Source code in src/fastapi_topaz/connection_pool.py
acquire
async
¶
Acquire a connection from the pool.
Returns an idle connection if available, creates a new one if under max_connections, or waits for one to become available.
| RAISES | DESCRIPTION |
|---|---|
TimeoutError
|
If acquire_timeout is exceeded |
Source code in src/fastapi_topaz/connection_pool.py
release
async
¶
Return a connection to the pool.
Source code in src/fastapi_topaz/connection_pool.py
connection
async
¶
Context manager for acquiring and releasing connections.
Source code in src/fastapi_topaz/connection_pool.py
status ¶
status() -> PoolStatus
Get current pool status for health checks.
Source code in src/fastapi_topaz/connection_pool.py
close
async
¶
Close all connections and shut down the pool.
Source code in src/fastapi_topaz/connection_pool.py
PoolStatus¶
Audit Logging¶
AuditLogger¶
Audit logger for authorization decisions.
| PARAMETER | DESCRIPTION |
|---|---|
log_allowed
|
Log successful authorizations
TYPE:
|
log_denied
|
Log denied authorizations
TYPE:
|
log_skipped
|
Log skipped/excluded routes
TYPE:
|
log_unauthenticated
|
Log 401 events
TYPE:
|
log_manual_checks
|
Log is_allowed(), check_relations()
TYPE:
|
level_allowed
|
Log level for allowed events
TYPE:
|
level_denied
|
Log level for denied events
TYPE:
|
level_unauthenticated
|
Log level for 401 events
TYPE:
|
level_skipped
|
Log level for skipped events
TYPE:
|
include_resource_context
|
Include resource context in logs
TYPE:
|
include_request_headers
|
Include HTTP headers (privacy concern)
TYPE:
|
handler
|
Custom async handler for events
TYPE:
|
log_decision
async
¶
log_decision(request: Request | None, policy_path: str, allowed: bool, *, source: str = 'dependency', check_type: str = 'policy', cached: bool = False, latency_ms: float | None = None, identity_type: str | None = None, identity_value: str | None = None, object_type: str | None = None, object_id: str | None = None, relation: str | None = None, subject_type: str | None = None, resource_context: dict[str, Any] | None = None, policy_resolution_source: str | None = None) -> None
Log an authorization decision.
Source code in src/fastapi_topaz/audit.py
log_batch_check
async
¶
log_batch_check(request: Request | None, object_type: str, object_id: str, results: dict[str, bool], *, latency_ms: float | None = None, identity_value: str | None = None) -> None
Log batch relation check results.
Source code in src/fastapi_topaz/audit.py
log_unauthenticated_event
async
¶
Log unauthenticated access attempt.
Source code in src/fastapi_topaz/audit.py
AuditEvent¶
Structured audit event for authorization decisions.
to_dict ¶
Convert to structured dict for logging.
Source code in src/fastapi_topaz/audit.py
Observability¶
PrometheusMetrics¶
Prometheus metrics collector for authorization decisions.
| PARAMETER | DESCRIPTION |
|---|---|
prefix
|
Metric name prefix (default: "topaz")
TYPE:
|
include_policy_path
|
Add policy_path label (high cardinality)
TYPE:
|
include_object_type
|
Add object_type label (medium cardinality)
TYPE:
|
include_relation
|
Add relation label (medium cardinality)
TYPE:
|
latency_buckets
|
Histogram buckets for latency
TYPE:
|
registry
|
Custom prometheus registry (default: global)
TYPE:
|
record_auth_request ¶
record_auth_request(source: str, decision: str, check_type: str, policy_path: str | None = None) -> None
Record an authorization request.
Source code in src/fastapi_topaz/observability.py
record_cache_hit ¶
record_cache_miss ¶
record_latency ¶
record_latency(latency_seconds: float, source: str, cached: bool, policy_path: str | None = None) -> None
Record authorization latency.
Source code in src/fastapi_topaz/observability.py
record_topaz_latency ¶
Record actual Topaz call latency.
Source code in src/fastapi_topaz/observability.py
record_error ¶
Record an authorization error.
set_circuit_state ¶
Set circuit breaker state (0=closed, 1=open, 2=half_open).
record_circuit_transition ¶
Record circuit state transition.
Source code in src/fastapi_topaz/observability.py
record_fallback ¶
Record circuit breaker fallback.
Source code in src/fastapi_topaz/observability.py
set_cache_size ¶
OTelTracing¶
OpenTelemetry tracing for authorization decisions.
| PARAMETER | DESCRIPTION |
|---|---|
trace_all_checks
|
Trace all authorization checks
TYPE:
|
trace_cache_operations
|
Include cache lookup/store spans
TYPE:
|
include_identity
|
Add identity to span attributes (privacy risk)
TYPE:
|
include_policy_path
|
Add policy_path to spans
TYPE:
|
include_resource_context
|
Add full resource context (privacy risk)
TYPE:
|
span_name_prefix
|
Prefix for span names
TYPE:
|
start_auth_span ¶
start_auth_span(source: str, check_type: str, policy_path: str | None = None, identity_value: str | None = None) -> Any
Start an authorization span.
Source code in src/fastapi_topaz/observability.py
end_auth_span ¶
end_auth_span(span: Any, decision: str, cached: bool, latency_ms: float, resource_context: dict | None = None) -> None
End an authorization span with results.
Source code in src/fastapi_topaz/observability.py
start_cache_span ¶
Start a cache operation span.
Source code in src/fastapi_topaz/observability.py
end_cache_span ¶
End a cache operation span.
Source code in src/fastapi_topaz/observability.py
start_topaz_span ¶
Start a Topaz request span.
end_topaz_span ¶
End a Topaz request span.
Source code in src/fastapi_topaz/observability.py
record_error ¶
Record an error on a span.
Source code in src/fastapi_topaz/observability.py
get_current_trace_id ¶
Get current trace ID for correlation.
Source code in src/fastapi_topaz/observability.py
Re-exported Types¶
These types are re-exported from aserto.client for convenience: