惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

J
Java Code Geeks
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
S
SegmentFault 最新的问题
博客园 - 三生石上(FineUI控件)
Hugging Face - Blog
Hugging Face - Blog
博客园 - Franky
云风的 BLOG
云风的 BLOG
I
InfoQ
小众软件
小众软件
Last Week in AI
Last Week in AI
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
大猫的无限游戏
大猫的无限游戏
A
About on SuperTechFans
Stack Overflow Blog
Stack Overflow Blog
The Cloudflare Blog
雷峰网
雷峰网
P
Proofpoint News Feed
腾讯CDC
H
Help Net Security
V
Visual Studio Blog
美团技术团队
F
Fortinet All Blogs
MongoDB | Blog
MongoDB | Blog
阮一峰的网络日志
阮一峰的网络日志

Cerbos - All Posts

Authentik vs Keycloak: Self-hosted IdP comparison Mapping business requirements to authorization policy for automotive Fine-grained authorization for AI gateways EIC 2026: Stop counting agents, protect what they can touch Agent skill for writing authorization policies in Claude Desktop Identity security in 2026 EIC 2026 takeaways: the identity stack built for humans will not hold up for AI agents Already have authentication? Here's the authorization layer you still need. Tokens are authorization decisions: a guide to policy-driven token issuance What is a Runtime Authorization Platform It's a dimmer switch, not a kill switch. How CISOs are rethinking AI agent governance From maps to bitmaps (and from bitmaps to bitmaps) AuthZEN, Shared Signals, SCIM Events, IPSIE: Notes from the OpenID Enterprise Panel How do you update authorization policies without redeploying your application? IIW42 recap: Where agent authorization got real Cerbos PDP v0.52.0/v0.53.0: Engine performance, security hardening, and CEL path functions Authorization Management Platforms: what they do, how they work, and where they fit PocketOS AI coding agent deleted a production database in 9 seconds Non-Human Identity management still has a blind spot Supabase alternative in 2026: Best open source auth options Benefits of on-premise authorization: Why enterprises are moving toward self-hosted Authorization policies: How to write, test, and validate them (faster with AI) Agent skill for writing authorization policies How much does it cost to build authorization in-house? Why centralized authorization governance reduces incident response time OPA alternative Why AI agents make authorization a right now problem Modernizing legacy application authorization: why it’s your biggest security blind spot How to add authorization to legacy applications without code changes 5 authorization blind spots auditors find, and how to fix them
Making Cerbos policies bulletproof with schemas
Alex Olivier · 2025-09-22 · via Cerbos - All Posts

Last month, I watched a developer debug a production authorization issue for three hours. The culprit? A typo in an attribute name. The policy expected departmentId, but the application was sending department_id. Classic.

This scenario plays out more often than you'd think. When you write Cerbos policies, you're essentially making assumptions about the shape of data your application will send. Without schemas, those assumptions are just that: assumptions. Your policies become a house of cards waiting for the wrong payload to knock everything down.

The problem with trusting your future self

Cerbos policies operate on attributes. Principal attributes describe who's making the request. Resource attributes describe what they're trying to access. By default, Cerbos accepts any JSON structure you throw at it. This flexibility feels great when you're prototyping, but it becomes a liability at scale.

I learned this the hard way at a previous gig. We had dozens of microservices, each sending slightly different attribute formats to our authorization layer. One service sent boolean values as strings. Another used snake_case while everyone else used camelCase. The authorization policies worked, technically, but understanding what data each policy expected required archaeology through multiple codebases.

What we needed was a contract. Something that would tell us immediately when a service sent the wrong shape of data. That's exactly what schemas give you in Cerbos.

How schemas actually work

Cerbos uses JSON Schema, specifically draft 2020-12. You define schemas for your principal and resource attributes, then reference them directly in your resource policies. The implementation is straightforward. You store your schemas in a _schemas directory at the root of your policy storage, then reference them in your policies.

Here's what caught my attention when I first started using them. You can compose schemas using standard JSON Schema features like $ref. If you have common attributes across multiple resources, define them once and reference them everywhere. No duplication, no drift.

The real power comes from the enforcement levels. Set Cerbos to warn mode during development to log validation errors without breaking anything. Once you're confident, switch to reject mode and watch invalid requests get blocked before they can cause damage.

Three wins you get immediately

Catch integration errors during testing, not in production. Remember that attribute name mismatch I mentioned? With schemas, your integration tests would fail immediately with a clear validation error pointing to the exact field that's wrong. No more debugging sessions that end with "oh, it's a typo."

Documentation that can't lie. Every developer on your team can look at a schema and know exactly what attributes a policy expects. The schema is the documentation, and Cerbos enforces it. I've seen teams reduce onboarding time for new developers by half just because they could understand the authorization requirements without diving into policy logic.

Prevent attribute injection attacks. Without schemas, a malicious actor could potentially send unexpected attributes that might interact with your policies in unintended ways. With schemas, you define exactly what attributes are allowed. Everything else gets rejected. It's like input validation for your authorization layer.

The gotcha that surprised everyone

During a workshop last year, several developers hit the same issue. They defined strict schemas for their resources, then wondered why CREATE actions kept failing. The resource doesn't exist yet during creation, so it might not have all the required attributes.

Cerbos thought of this. You can use the ignoreWhen directive to skip schema validation for specific actions. Set it up for CREATE and DELETE operations where your resource might be in a transitional state. This flexibility lets you be strict where it matters while staying practical where you need to be.

Making schemas work with your workflow

Start small. Pick one critical resource type and define schemas for it. Run in warn mode for a week and watch your logs. You'll quickly see patterns in validation errors that point to inconsistencies in your system.

I typically define a base principal schema that all resources share, then extend it for specific use cases. Same with resources. Build a library of common attribute definitions and compose them as needed. Think of it like building with LEGO blocks rather than sculpting from clay.

The migration path is smooth. Existing policies without schemas continue to work. You add schemas resource by resource, gradually increasing coverage. No big-bang deployments, no service interruptions.

What happens when you don't use schemas

A customer once told me about their "Friday afternoon incident." A developer pushed a small change that accidentally renamed a critical attribute. The policies still loaded fine. The application started fine. But every authorization check that relied on that attribute started failing in subtle ways.

Without schemas, these errors manifest as incorrect authorization decisions. Users might get access they shouldn't have, or lose access they should have. You won't get a clear error message. You'll get confused users and a lot of head-scratching.

With schemas, that same change would have been caught immediately. Either during testing if you have good coverage, or at runtime with a clear validation error. The difference between a five-minute fix and a weekend war room.

The security angle nobody talks about

Schemas do more than prevent bugs. They create an auditable specification of your authorization requirements. During security reviews, auditors can examine your schemas to understand exactly what data drives authorization decisions. No guesswork, no assumptions.

I've watched security teams breathe a sigh of relief when they realize they can review schemas instead of parsing through policy logic to understand data dependencies. It transforms authorization from a black box into a well-defined system with clear inputs and outputs.

Your schemas become part of your security posture. They document not just what you accept, but what you explicitly reject. That's powerful when you need to demonstrate compliance or investigate an incident.

Getting started without overthinking it

Write your first schema. Make it simple. Cover the basic attributes you know every principal will have: id, roles, maybe department. Store it in _schemas/principal.json. Reference it in one resource policy. Set enforcement to warn. Deploy it.

Watch what happens for a day. Fix any validation errors that pop up. Once clean, switch to reject mode. Congratulations, you've just made your authorization system significantly more robust.

The overhead is minimal. The safety you gain is substantial. Every team I've worked with that adopted schemas wondered why they didn't do it sooner. Stop trusting your authorization to unvalidated data. Define your contracts, enforce them, and sleep better knowing your policies work with the data they actually receive.

If you haven’t tried Cerbos Hub yet, you can learn more and try it for free here. You can also book a call with a Cerbos engineer to see how our solution can help streamline access control in your applications.