AuthLayer, you can enforce specific access control policies using Permission Layers. These layers reject unauthorized requests with a 403 Forbidden status code before they ever reach your business logic.
Note: The AuthLayer MUST be applied before any Permission Layers.
Basic Scope Checks
Wacht supports Role-Based Access Control (RBAC) at two scopes: Organization and Workspace. The SDK provides shorthand layer constructors for both.Complex Logic
You can enforce more complex logic usingMultiplePermissionLayers and RequireAnyPermissionLayer.
Requiring ALL Permissions (AND)
If an endpoint requires a combination of permissions, useMultiplePermissionLayers::all().
Requiring ANY Permission (OR)
If an endpoint can be accessed by multiple different roles, useMultiplePermissionLayers::any() or the RequireAnyPermissionLayer directly.
Layer Ordering is Critical
Axum executes layers starting from the one applied last. Because Permission layers rely on the context injected by theAuthLayer, you must call .layer(AuthLayer::new()) after your permission layers.
RequireAuth extractor directly instead.