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

推荐订阅源

D
Docker
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
C
Cisco Blogs
Scott Helme
Scott Helme
Know Your Adversary
Know Your Adversary
NISL@THU
NISL@THU
C
Cyber Attacks, Cyber Crime and Cyber Security
D
Darknet – Hacking Tools, Hacker News & Cyber Security
C
CXSECURITY Database RSS Feed - CXSecurity.com
S
Schneier on Security
I
Intezer
Spread Privacy
Spread Privacy
AWS News Blog
AWS News Blog
V
Vulnerabilities – Threatpost
Cloudbric
Cloudbric
V2EX - 技术
V2EX - 技术
Google Online Security Blog
Google Online Security Blog
L
Lohrmann on Cybersecurity
Recent Commits to openclaw:main
Recent Commits to openclaw:main
L
LINUX DO - 热门话题
S
Secure Thoughts
T
The Exploit Database - CXSecurity.com
博客园 - 【当耐特】
Recent Announcements
Recent Announcements
Security Archives - TechRepublic
Security Archives - TechRepublic
Stack Overflow Blog
Stack Overflow Blog
罗磊的独立博客
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
K
Kaspersky official blog
阮一峰的网络日志
阮一峰的网络日志
博客园_首页
Latest news
Latest news
B
Blog
F
Full Disclosure
大猫的无限游戏
大猫的无限游戏
博客园 - 叶小钗
L
LangChain Blog
GbyAI
GbyAI
Last Week in AI
Last Week in AI
S
Security Affairs
Apple Machine Learning Research
Apple Machine Learning Research
N
Netflix TechBlog - Medium
Security Latest
Security Latest
Vercel News
Vercel News
Y
Y Combinator Blog
G
GRAHAM CLULEY
S
Securelist
T
Troy Hunt's Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
雷峰网
雷峰网

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
How to Stop Permission Creep Using Role-Based Toolbar Access
Froala · 2026-05-20 · via DEV Community

You’re building a document management system. Your first instinct is simple: editors can do everything, and everyone else is locked out. But then requests start arriving.

Legal needs to export PDFs. You make them editors. A week later, you realize they’ve accidentally deleted three documents.

Finance needs to print reports. You add them to the editor role too. Now they’re changing numbers.

Customer success wants to view documents in fullscreen during calls. You give them editor access because that’s the only way to unlock fullscreen. They’re now modifying customer contracts.

Each time, the reasoning is the same: “We just need them to have access to one thing.” Each time, you grant a role full editing permissions because your editor only understands two states — completely on or completely off. There is no middle ground.

This is permission creep. It happens in almost every content application. You end up with too many people who can edit, which means you need auditing, version history, and approval workflows just to contain the damage. Your security posture degrades. Your data integrity suffers. And your codebase fills with conditional logic trying to patch the gap between what people actually need and what your permission system can offer.

The root cause is a false equivalence: Can edit should never mean can print, export, view source, or take any other action. These should be independent permissions. But most editors — including Froala by default — conflate them. You unlock one button, you unlock everything.

Froala’s toolbarButtonsEnabledOnEditorOff solves this. It lets you lock content for editing while preserving a granular whitelist of allowed actions. The result is a permission model where you never again have to grant someone full editing access just to unlock one button.

Key Takeaways

  • Permission creep happens when you conflate “can edit” with every other action. Most editors force you to choose: full access or nothing. This creates pressure to over-grant permissions.
  • Break the tie with toolbarButtonsEnabledOnEditorOff**.** You can now lock editing while keeping specific buttons active—print, export, approve, archive, whatever your workflow needs.
  • Design your permission model before coding. Create a role-to-action matrix, get stakeholder alignment, then implement. This prevents ad-hoc decisions from accumulating.
  • Centralize permissions in code. One rolePermissions object. One getPermissions() function. Reference it everywhere. Make it the source of truth.
  • Always validate on the backend. The frontend toolbar is UX guidance, not a security boundary. Your server must enforce every permission independently.
  • Default to the most restrictive access. Unknown roles get minimal permissions. Missing auth fails closed. Unrecognized states lock everything down.

The Permission Creep Trap

Here’s what typically happens. You start with a simple role system:

  • Editor: can edit everything
  • Viewer: can see everything, can’t do anything

This works for two weeks. Then:

  • Legal asks to export PDFs → you make Legal an editor
  • Finance asks to print → you make Finance an editor
  • Support asks for fullscreen mode → you make Support an editor
  • A partner needs to view HTML source → you make Partners an editor

Now your “editor” role has seventeen different use cases, and half of them have no business editing content. You’ve created a security surface area you didn’t intend. Worse, you’ve created a maintenance nightmare: every new request forces you to either grant editing access (bad) or tell the user “no” (frustrating).

The fundamental problem is that your editor’s default behavior ties toolbar access to editing access. Turn off editing with edit.off(), and the entire toolbar goes dark. No print button. No export. Nothing. So developers reach for the only lever they have: make people editors.

Understanding the Solution

toolbarButtonsEnabledOnEditorOff breaks that tie. It lets you disable editing while keeping specific toolbar buttons active. Instead of “can edit or can’t do anything,” you now have granular control:

  • Editor: full toolbar, can edit
  • Legal: read-only, but can export PDFs
  • Finance: read-only, but can print
  • Support: read-only, but can open fullscreen
  • Viewer: completely locked down

Each role gets exactly what it needs. No more, no less. No more false choices between granting full access or granting nothing.

The supported buttons are print, fullscreen, export_to_word, getPDF, and html. You can also define custom buttons (like “Approve,” “Share,” or “Archive”) that stay active in read-only mode. This scales cleanly as your workflows grow.

Building a Permission Model That Doesn’t Creep

The key to avoiding permission creep is to design your roles intentionally before you start coding. Not after the first request arrives — before.

Start by listing every action a user might need to perform in your document editor. Don’t just think about editing. Think about:

  • Editing content
  • Printing
  • Exporting to PDF
  • Exporting to Word
  • Viewing HTML source
  • Fullscreen mode
  • Sharing
  • Approving
  • Rejecting
  • Archiving
  • Creating versions
  • Comparing versions

Then, for each role in your system, decide which actions they should have. Be specific. Don’t say “Legal can do what they need” — say “Legal can export to PDF and print, but cannot edit or delete.”

Write it down. Make it a table. Show it to your product manager, your security team, your legal team. Get alignment before you write code. This prevents a thousand small decisions from accumulating into permission creep.

Implementing the Permission Model

Once your matrix is locked in, translate it into code. Create a single configuration object that mirrors your table.

const rolePermissions = {
  editor: {
    canEdit: true,
    allowedWhenReadOnly: []
  },
  reviewer: {
    canEdit: false,
    allowedWhenReadOnly: ['print', 'fullscreen', 'html', 'approveDocument']
  },
  legal: {
    canEdit: false,
    allowedWhenReadOnly: ['print', 'getPDF', 'export_to_word', 'archiveDocument']
  },
  finance: {
    canEdit: false,
    allowedWhenReadOnly: ['print', 'getPDF']
  },
  viewer: {
    canEdit: false,
    allowedWhenReadOnly: []
  }
};

Enter fullscreen mode Exit fullscreen mode

Keep this object at the top level of your code. Make it easy to find. Make it easy to modify. This is your permission source of truth — if you change the matrix, you change this object and only this object.

Notice a few important details:

  • The editor role has an empty allowedWhenReadOnly array because editors aren’t in read-only mode.
  • The viewer role has no buttons at all, not even print. Be explicit about the minimum viable access.
  • If a role needs a custom action (like approveDocument or archiveDocument), include it here.
  • Unknown roles should fall back to viewer (the lowest privilege).

Initializing the Editor with Role-Based Permissions

With your permission object in place, use it to configure Froala at initialization time:

function createEditor(role) {
  // Fallback to viewer if role is unknown
  const permissions = rolePermissions[role] || rolePermissions.viewer;

  new FroalaEditor('#editor', {
    toolbarButtonsEnabledOnEditorOff: permissions.allowedWhenReadOnly,
    events: {
      initialized: function() {
        if (!permissions.canEdit) {
          this.edit.off();
        }
      }
    }
  });
}

// Get the current user's role from your auth system
const currentUserRole = window.currentUser.role;
createEditor(currentUserRole);

Enter fullscreen mode Exit fullscreen mode

This pattern ensures that:

  1. The editor starts in the correct state immediately — no flicker, no race conditions.
  2. Role logic is centralized — you’re not scattering permission checks throughout your code.
  3. Unknown or missing roles default to the most restrictive access — if something goes wrong, users get locked out, not given too much access.
  4. Adding a new role is a single-line change: add it to the rolePermissions object.

Loading Roles Dynamically from Your Auth System

In a real application, the role comes from your authentication layer or an API. Load it before initializing the editor:

async function initEditor() {
  try {
    const response = await fetch('/api/current-user');
    const user = await response.json();

    createEditor(user.role);
  } catch (error) {
    // Fail securely: default to viewer if auth fails
    console.error('Failed to load user role:', error);
    createEditor('viewer');
  }
}

initEditor();

Enter fullscreen mode Exit fullscreen mode

Fail securely. If authentication fails or the role is missing, default to the most restrictive role. Never assume access.

Adding Custom Buttons for Workflow Actions

Generic buttons like print and export aren’t always enough. You may need custom buttons for workflow-specific actions like “Approve,” “Request Changes,” or “Archive.”

Define custom buttons the same way you define roles — centrally, in configuration:

// Register custom button icons and handlers
FroalaEditor.DefineIcon('approveDocument', { NAME: 'check', SVG_KEY: 'check' });
FroalaEditor.RegisterCommand('approveDocument', {
  title: 'Approve Document',
  focus: false,
  undo: false,
  refreshAfterCallback: false,
  callback: function() {
    approveDocument();
  }
});

FroalaEditor.DefineIcon('requestChanges', { NAME: 'edit', SVG_KEY: 'edit' });
FroalaEditor.RegisterCommand('requestChanges', {
  title: 'Request Changes',
  focus: false,
  undo: false,
  refreshAfterCallback: false,
  callback: function() {
    requestChanges();
  }
});

// Add these to your role permissions
const rolePermissions = {
  reviewer: {
    canEdit: false,
    allowedWhenReadOnly: ['print', 'fullscreen', 'html', 'approveDocument', 'requestChanges']
  },
  // ... other roles
};

Enter fullscreen mode Exit fullscreen mode

These custom buttons work beautifully in read-only mode. A reviewer can’t edit the document, but they can approve it. Legal can’t change anything, but they can request changes. This is precise permission control.

Document-State-Aware Permissions

Permissions often depend not just on role, but on document status. A document in draft mode might allow edits from anyone with the editor role. Once it’s finalized, only admins can make changes. Combine role and state:

function getPermissions(role, documentStatus) {
  const basePermissions = rolePermissions[role] || rolePermissions.viewer;

  // If the document is finalized, lock down all editing
  if (documentStatus === 'finalized') {
    return {
      canEdit: false,
      allowedWhenReadOnly: basePermissions.allowedWhenReadOnly.filter(
        btn => ['print', 'getPDF', 'fullscreen'].includes(btn)
      )
    };
  }

  // If under review, reviewers can approve but nobody can edit
  if (documentStatus === 'under_review') {
    if (role === 'reviewer') {
      return {
        canEdit: false,
        allowedWhenReadOnly: ['print', 'fullscreen', 'html', 'approveDocument', 'requestChanges']
      };
    }
    return {
      canEdit: false,
      allowedWhenReadOnly: ['print', 'fullscreen']
    };
  }

  // Draft mode: use base permissions
  return basePermissions;
}

// Use it during initialization
const permissions = getPermissions(currentUserRole, currentDocumentStatus);
new FroalaEditor('#editor', {
  toolbarButtonsEnabledOnEditorOff: permissions.allowedWhenReadOnly,
  events: {
    initialized: function() {
      if (!permissions.canEdit) {
        this.edit.off();
      }
    }
  }
});

Enter fullscreen mode Exit fullscreen mode

This prevents permission creep at the workflow level. As your document lifecycle grows, you update getPermissions() once. You don’t scatter state logic throughout your codebase.

The Critical Backend Check

Here’s the part people forget: none of this matters if your backend doesn’t validate permissions.

The toolbar is a UX layer. A determined user can open the browser console and call editor.edit.on(). They can forge API requests. They can do anything the client allows. Your server must independently verify every action.

When a user exports a document, your backend should check: “Does this user’s role allow exports?” When they approve a document, check: “Is this document in a state where approvals are allowed?” When they try to edit, verify: “Can this role edit at this time?”

Never trust the client. The toolbar is for helping honest users understand their access level. It’s not a security boundary.

// Backend example: validating export permissions
app.post('/api/documents/:id/export', async (req, res) => {
  const user = req.user; // from auth middleware
  const document = await Document.findById(req.params.id);
  const userRole = user.role;

  // Check: does this role have export permission?
  const permissions = rolePermissions[userRole] || rolePermissions.viewer;  
if (!permissions.allowedWhenReadOnly.includes('getPDF')) {
    return res.status(403).json({ error: 'Export not allowed for your role' }); 
 }
  // Check: is the document in a state where export is allowed?
  if (document.status === 'draft' && userRole !== 'editor') {    return res.status(403).json({ error: 'Cannot export draft documents' });  }

  // Permission check passed. Now generate the export.
  const pdf = await generatePDF(document); 
  res.download(pdf);});

Enter fullscreen mode Exit fullscreen mode

The pattern: always validate against your permission model on the server. The frontend toolbar is just a convenience — the real enforcement happens here.

Conclusion

Permission creep happens when you treat “can edit” as synonymous with every other action. It’s a false equivalence that forces you to grant full access to solve partial problems.

toolbarButtonsEnabledOnEditorOff lets you break that equivalence. Combined with a clear permission matrix, centralized configuration, and backend validation, it becomes your defense against creep.

The pattern is simple: design your roles intentionally before coding, implement them in one place, validate them on the server, and refuse to add exceptions. Each decision you defer is a decision that will compound. Make them upfront, make them visible, and make them stick.

Your future self will thank you when you’re not maintaining seventeen ad-hoc permissions five years from now.

Try our working demo on JSFiddle, or download Froala and build one yourself.

Originally published on the Froala blog.