Directory supports fine-grained authorization policies that control which SPIFFE trust domains can access specific API methods. Authorization policies work in conjunction with authentication (either X.509-SVID or JWT-SVID) to provide comprehensive access control.
Authorization policies use a simple CSV format based on Casbin:
p,<trust_domain>,<api_method>
Where:
trust_domain: SPIFFE trust domain extracted from the client's X.509-SVID or JWT-SVIDapi_method: gRPC method name in the format/package.Service/Method
Policies support multiple matching strategies:
- Exact matching: Match specific trust domain and API method
- Wildcard matching: Use
*to match any value - Prefix matching: Use patterns like
/service/*to match all methods under a path - Regex matching: Use regular expressions for complex patterns
The authorization system evaluates policies using both keyMatch (for prefix patterns) and regexMatch (for regular expressions).
Allow full access for your trust domain:
p,example.org,*
Allow read-only access for external trust domains:
p,*,/agntcy.dir.store.v1.StoreService/Pull
p,*,/agntcy.dir.store.v1.StoreService/PullReferrer
p,*,/agntcy.dir.store.v1.StoreService/Lookup
Allow sync operations only for dedicated sync services:
p,sync.example.org,/agntcy.dir.sync.v1.SyncService/*
Allow access for all subdomains using regex:
p,^.*\.example\.org$,*
Mixed policy (internal full access, external read-only):
# Full access for internal services
p,example.org,*
# Read-only access for external partners
p,partner1.com,/agntcy.dir.store.v1.StoreService/Pull
p,partner1.com,/agntcy.dir.store.v1.StoreService/PullReferrer
p,partner1.com,/agntcy.dir.store.v1.StoreService/Lookup
# Another partner with different requirements
p,partner2.com,/agntcy.dir.store.v1.StoreService/Pull
p,partner2.com,/agntcy.dir.sync.v1.SyncService/RequestRegistryCredentials
Store Service:
/agntcy.dir.store.v1.StoreService/Push- Create or update records/agntcy.dir.store.v1.StoreService/Pull- Retrieve records/agntcy.dir.store.v1.StoreService/Lookup- Search for records/agntcy.dir.store.v1.StoreService/Delete- Remove records/agntcy.dir.store.v1.StoreService/PushReferrer- Create referrer relationships/agntcy.dir.store.v1.StoreService/PullReferrer- Retrieve referrer relationships
Sync Service:
/agntcy.dir.sync.v1.SyncService/CreateSync- Initiate sync operations/agntcy.dir.sync.v1.SyncService/ListSyncs- List sync operations/agntcy.dir.sync.v1.SyncService/GetSync- Get sync status/agntcy.dir.sync.v1.SyncService/DeleteSync- Cancel sync operations/agntcy.dir.sync.v1.SyncService/RequestRegistryCredentials- Request credentials for sync
To enable authorization policies in your Helm deployment:
authz_policies_csv: |
p,example.org,*
p,*,/agntcy.dir.store.v1.StoreService/Pull
p,*,/agntcy.dir.store.v1.StoreService/PullReferrer
p,*,/agntcy.dir.store.v1.StoreService/Lookup
config:
# Authentication must be enabled first
authn:
enabled: true
mode: "x509" # or "jwt"
socket_path: "unix:///run/spire/agent-sockets/api.sock"
# Authorization policies
authz:
enabled: true
enforcer_policy_file_path: "/etc/agntcy/dir/authz_policies.csv"Important: Authorization requires authentication to be enabled. The authorization system extracts the trust domain from the authenticated SPIFFE ID (either from X.509-SVID or JWT-SVID) and evaluates it against the configured policies.