Migrating from Flat Permissions
require_permissions reads a flat list from request.state.current_user; SqlPermissionsProvider reads a
global table authz_permissions(username, permission). Neither knows which tenant a request is
about. Nothing here changes or is removed; migrate route by route.
Model your tenants as a scope kind and your old permissions as catalog entries (The Permission Catalog). Group permissions into roles.
Load the old rows into assignments (one per principal and scope), for example with
AssignmentService.assignorauthcli authz assign.Replace
Depends(require_permissions(["x"]))withDepends(require_permission("x", scope=ScopeFromPath("tenant", "tenant_id")))and read theAuthzContextit returns.Platform-wide staff: map token groups to a role with
group_roles={"staff": "PLATFORM_ADMIN"}.Keep
AUTH_MIDDLEWARE_DISABLEDout of environments that use the new guard:installrefuses it.
The legacy authz_permissions table is independent of authz_assignment; both can coexist.