Add policy-based authorization to Gin HTTP handlers and middleware using the Cerbos Go SDK. Enforce fine-grained access control at the router level without hard-coding permission logic in handlers.
Add Cerbos checks as Gin middleware to enforce permissions before requests reach your handler functions
Pass user identity and resource attributes through Gin's context, giving Cerbos the information it needs for attribute-based decisions
Move authorization rules out of handler functions and into versioned YAML policies that can be updated without recompiling your Go application
Building authorization logic inside Gin quickly becomes a maintenance burden. Hard-coded role checks scatter across controllers and middleware, and every permission change requires a code deploy.
Cerbos replaces scattered authorization logic with a single API call. You define fine-grained policies in YAML, and the Cerbos PDP evaluates them at request time using roles, attributes, and any context you provide.
With Cerbos your Gin application stays focused on business logic while authorization policies evolve independently, managed by product or security teams without touching code.
Use the Cerbos Go SDK to create a client and call the Cerbos PDP from your Gin handlers or middleware. Build a middleware function that extracts the authenticated user from the Gin context, calls Cerbos to check permissions, and either allows the request to proceed or returns a 403.
Yes. Create a Gin middleware function that extracts the principal and resource information from the request context, calls the Cerbos PDP, and uses c.Abort() to block unauthorized requests. Attach it to specific routes or route groups. The Cerbos PDP responds in sub-millisecond time.
The Cerbos Go SDK accepts a context.Context, so it integrates naturally with Gin's request lifecycle. Pass gin.Context's underlying context to the Cerbos client, ensuring cancellation and timeouts propagate correctly.



What is Cerbos?
Cerbos is an end-to-end enterprise authorization software for Zero Trust environments and AI-powered systems. It enforces fine-grained, contextual, and continuous authorization across apps, APIs, AI agents, MCP servers, services, and workloads.
Cerbos consists of an open-source Policy Decision Point, Enforcement Point integrations, and a centrally managed Policy Administration Plane (Cerbos Hub) that coordinates unified policy-based authorization across your architecture. Enforce least privilege & maintain full visibility into access decisions with Cerbos authorization.