<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Coder Legion - Recent posts tagged roles</title>
<link>https://coderlegion.com/tag/roles</link>
<description>Powered by Question2Answer</description>
<item>
<title>Directus Basics Part 3 — User Roles &amp; Permissions</title>
<link>https://coderlegion.com/25060/directus-basics-part-3-user-roles-permissions</link>
<description>&lt;p&gt;This is part three of our Directus Basics series. In &lt;a rel=&quot;nofollow&quot; href=&quot;https://www.youtube.com/watch?v=tJGuxqhv2SY&amp;amp;t=12s&quot;&gt;part one&lt;/a&gt; we set up our instance, and in &lt;a rel=&quot;nofollow&quot; href=&quot;https://www.youtube.com/watch?v=7SNrBzaxreg&amp;amp;t=108s&quot;&gt;part two&lt;/a&gt; we covered relationships between collections. Today we're covering access control — what determines who can see and touch your data.&lt;/p&gt;
&lt;p&gt;Part III - &lt;a rel=&quot;nofollow&quot; href=&quot;https://www.youtube.com/watch?v=qAk3X4y8v1U&quot;&gt;Youtube&lt;/a&gt;&lt;/p&gt;
&lt;h3 id=&quot;the-core-concepts&quot;&gt;The Core Concepts&lt;/h3&gt;
&lt;p&gt;Access control in Directus comes down to three terms:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Permission&lt;/strong&gt; — applies to one collection and one action (create, read, update, delete, or share). Can be full access, no access, or custom rules.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Policy&lt;/strong&gt; — a group of permissions bundled together, applied to users or roles.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Role&lt;/strong&gt; — defines a user's position within a project. A role can hold any number of policies, apply to any number of users, and have child roles of its own.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;what-happens-without-a-role-&quot;&gt;What Happens Without a Role?&lt;/h3&gt;
&lt;p&gt;If an administrator creates a user but doesn't assign a role, that user has valid login credentials but still can't access the Data Studio.&lt;/p&gt;
&lt;p&gt;Creating a role and assigning the user to it isn't enough either — logging in at that point returns a &lt;strong&gt;&quot;No App Access&quot;&lt;/strong&gt; error. The missing piece is that the role has no &lt;strong&gt;access policy&lt;/strong&gt; attached. The policy is what actually tells the role what its users can and can't do.&lt;/p&gt;
&lt;h3 id=&quot;the-access-order&quot;&gt;The Access Order&lt;/h3&gt;
&lt;p&gt;Access in Directus flows in a specific direction:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Access Policy → Role → User&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;In practice: define what level of access a user needs, build an access policy to match, create a role and attach that policy to it, then register the user and assign them to the role.&lt;/p&gt;
&lt;h3 id=&quot;default-policies&quot;&gt;Default Policies&lt;/h3&gt;
&lt;p&gt;Every fresh Directus instance ships with two default policies:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Administrator&lt;/strong&gt; — the role you're signed in as by default, with unrestricted access to everything.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Public&lt;/strong&gt; — for data that should be visible without logging in. Think of a product catalog on an e-commerce site — forcing a login just to browse products is a poor experience.&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;&lt;p&gt;&lt;strong&gt;Rule of thumb:&lt;/strong&gt; give the Public policy Read access only. Never Create, Update, or Delete. The public should be able to view data, never manipulate it.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h4 id=&quot;giving-a-collection-public-access&quot;&gt;Giving a Collection Public Access&lt;/h4&gt;
&lt;ol&gt;
&lt;li&gt;Go to &lt;strong&gt;Settings&lt;/strong&gt; → &lt;strong&gt;Access Policies&lt;/strong&gt; → &lt;strong&gt;Public&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Under Permissions, click &lt;strong&gt;Add Collection&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Select &lt;strong&gt;products&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Read&lt;/strong&gt;, choose &lt;strong&gt;All Access&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Save&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&quot;creating-a-custom-access-policy&quot;&gt;Creating a Custom Access Policy&lt;/h3&gt;
&lt;p&gt;Let's build a policy for a data-entry team member with limited access.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Go to &lt;strong&gt;Access Policies&lt;/strong&gt;, click &lt;strong&gt;Create&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Name it &lt;code&gt;DataEntry&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Check &lt;strong&gt;App Access&lt;/strong&gt; — leave &lt;strong&gt;Admin Access&lt;/strong&gt; unchecked, since that grants unrestricted control&lt;/li&gt;
&lt;li&gt;Save&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Directus populates the policy with minimum defaults for its own system collections, but nothing for your custom collections yet.&lt;/p&gt;
&lt;p&gt;Add products to it:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Click &lt;strong&gt;Add Collection&lt;/strong&gt;, select &lt;code&gt;products&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Read&lt;/strong&gt;, choose &lt;strong&gt;All Access&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Save&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&quot;creating-the-user-role&quot;&gt;Creating the User Role&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;Go to &lt;strong&gt;User Roles&lt;/strong&gt;, click &lt;strong&gt;Create&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Name it &lt;code&gt;DataEntry&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Under Policies, click &lt;strong&gt;Add Existing&lt;/strong&gt;, select the &lt;code&gt;DataEntry&lt;/code&gt; policy&lt;/li&gt;
&lt;li&gt;Save&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&quot;creating-the-user&quot;&gt;Creating the User&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;Go to &lt;strong&gt;User Directory&lt;/strong&gt;, click &lt;strong&gt;Create&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Fill in first name, last name, email, and password&lt;/li&gt;
&lt;li&gt;Under &lt;strong&gt;Role&lt;/strong&gt;, select &lt;code&gt;DataEntry&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Save&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;If you check back on &lt;strong&gt;User Roles&lt;/strong&gt;, you'll see a &lt;code&gt;1&lt;/code&gt; next to DataEntry under Users, and a matching &lt;code&gt;1&lt;/code&gt; under Access Policies. That confirms the role, policy, and user are all wired together correctly.&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;&lt;strong&gt;Tip:&lt;/strong&gt; giving your policy and role the same name (as done here with &quot;DataEntry&quot;) makes them much easier to track as your project grows.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3 id=&quot;testing-read-only-access&quot;&gt;Testing Read-Only Access&lt;/h3&gt;
&lt;p&gt;Log in as the new user. You'll see the products collection, but attempting to edit any field does nothing — expected, since only Read access was granted.&lt;/p&gt;
&lt;p&gt;Scrolling to the bottom of a product's detail page, some data is simply missing — those fields belong to &lt;em&gt;other&lt;/em&gt; collections the user doesn't yet have permission for. The product image is missing too.&lt;/p&gt;
&lt;h3 id=&quot;fixing-the-missing-file-permission&quot;&gt;Fixing the Missing File Permission&lt;/h3&gt;
&lt;p&gt;Back in the &lt;code&gt;DataEntry&lt;/code&gt; policy, notice &lt;strong&gt;&lt;code&gt;directus_files&lt;/code&gt;&lt;/strong&gt; isn't included among the accessible system collections. Without it, uploaded files — including product images — stay invisible.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Click &lt;strong&gt;Add Collection&lt;/strong&gt;, select &lt;code&gt;directus_files&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Read&lt;/strong&gt;, choose &lt;strong&gt;All Access&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Save&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Log back in as the data-entry user, and the product image now appears.&lt;/p&gt;
&lt;h4 id=&quot;adding-the-thumbnail-to-list-view&quot;&gt;Adding the Thumbnail to List View&lt;/h4&gt;
&lt;ol&gt;
&lt;li&gt;In list view, click the &lt;strong&gt;+&lt;/strong&gt; icon on the right&lt;/li&gt;
&lt;li&gt;Scroll to &lt;strong&gt;image&lt;/strong&gt;, click the arrow next to it — not the field name itself, or you'll add the raw file ID instead of the thumbnail&lt;/li&gt;
&lt;li&gt;Scroll to &lt;strong&gt;thumbnail&lt;/strong&gt;, click outside the dropdown to confirm&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Drag column headers to reorder them as needed.&lt;/p&gt;
&lt;h3 id=&quot;extending-access-to-related-collections&quot;&gt;Extending Access to Related Collections&lt;/h3&gt;
&lt;p&gt;The same missing-permission pattern applies to &lt;strong&gt;branding&lt;/strong&gt;, &lt;strong&gt;products_tags&lt;/strong&gt; and &lt;strong&gt;tags&lt;/strong&gt; — add all to the &lt;code&gt;DataEntry&lt;/code&gt; policy with Read access, and the relational fields on products become visible.&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;&lt;strong&gt;Key takeaway:&lt;/strong&gt; you can't access a relational field in one collection unless you also have permission on the &lt;em&gt;related&lt;/em&gt; collection. Both sides of the relationship need coverage.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3 id=&quot;custom-field-level-permissions&quot;&gt;Custom Field-Level Permissions&lt;/h3&gt;
&lt;p&gt;Sometimes all-or-nothing collection access isn't granular enough. Directus lets you restrict access down to individual fields.&lt;/p&gt;
&lt;p&gt;Let's allow the data-entry user to update only the &lt;code&gt;name&lt;/code&gt; field on products:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;On the products collection, click the &lt;strong&gt;Update&lt;/strong&gt; action&lt;/li&gt;
&lt;li&gt;Choose &lt;strong&gt;Use Custom&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Field Permissions&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Check &lt;strong&gt;Name&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Save, then save again&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Logging back in, the data-entry user can now edit the Name field — and nothing else on that collection.&lt;/p&gt;
&lt;h3 id=&quot;summary&quot;&gt;Summary&lt;/h3&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;&lt;th&gt;Concept    &lt;/th&gt;&lt;th&gt;Definition&lt;/th&gt;&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;Permission &lt;/td&gt;&lt;td&gt;One collection + one action, set to full/none/custom&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Policy     &lt;/td&gt;&lt;td&gt;A bundle of permissions, applied to users or roles&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Role       &lt;/td&gt;&lt;td&gt;A user's position in the project; holds policies, applies to users&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;Access control in Directus is genuinely one of its most powerful features — this covers the fundamentals, but there's plenty more granularity available as your project grows.&lt;/p&gt;
&lt;p&gt;That wraps part three. Next up, we'll look at how everything from this series comes together once we start pulling this data into a real front end.&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;&lt;em&gt;Found this useful? Follow for more Directus and TanStack Start tutorials, or check out the video version above.&lt;/em&gt;&lt;/p&gt;
</description>
<category>Articles</category>
<guid isPermaLink="true">https://coderlegion.com/25060/directus-basics-part-3-user-roles-permissions</guid>
<pubDate>Fri, 21 Aug 2026 06:23:23 +0000</pubDate>
</item>
</channel>
</rss>