9f2e59ad1a test(authz): cover tenant isolation and fail-closed HTTP decisions (#6)
The serve package mounts the network edge of the access decision
(POST /v1/authz/check) and had no tests. Add in-process route tests
through zip's test transport: unauthenticated refusal, cross-tenant
target and grant-scope refusal, malformed-path and missing-field 400s,
owner/admin/member allow and deny, narrower-scope prefix narrowing,
expired-grant denial, and fail-closed on unknown verb and role.

Co-authored-by: harshitgavita-07 <[email protected]>
2026-10-27 20:52:58 -07:00

Hanzo Authz

The access-control library every Hanzo Go service uses to read a token and decide whether a caller may do a thing: JWT verification, claims, and the grant calculus over organizations, apps and paths.

Install

go get github.com/hanzoai/authz

Use it

Verify a token — this is the same library IAM signs with, so a reader here cannot disagree with the issuer about what was signed:

claims, err := authz.Verify(token, keys, []string{"https://hanzo.id"})

keys is a func(kid string) []crypto.PublicKey. Key material is an input: fetching and caching a JWKS is I/O, and this package does none — the edge owns the fetch and hands the result in. A nil Keys, or one that resolves nothing, verifies nothing.

From there, Claims carries the caller's identity, org memberships and app grants; ParsePath and VerbOf turn a request into the pair the grant calculus decides on. IsAPIKey distinguishes an hk- key from a JWT.

Only the algorithms IAM's signer produces are accepted — RSA and EC, plus ML-DSA-65 for a post-quantum certificate. none and HMAC are rejected.

Docs

LLM.md for the layout. The edge/ and serve/ packages hold the pieces that do need I/O — key fetching and the HTTP surface — kept out of the leaf on purpose.

License

See LICENSE.

S
Description
Hanzo Authz — access control library for Go: ACL, RBAC, ABAC policy enforcement
Readme Apache-2.0
2.9 MiB
Languages
Go 94.6%
Python 4%
JavaScript 1.3%