Designing permissions
Signing someone in settles who they are. What they may then do is a separate design problem, and it starts with naming the actions a service can allow or refuse. This lesson follows a newsroom's photo library from one all-or-nothing switch to a catalog of permissions that the service checks on every request.
From one flag to many permissions
The Tidewell Gazette, a fictional newspaper, keeps its newsroom pictures in a shared photo library on the photo service. Photographers upload, editors approve publication, and the legal team places holds. Theo, the library administrator, needs to give each person enough access to do their work.
The first library had one choice: administrator or reader. Administrators could upload, approve, delete and manage other accounts. Readers could browse. That seemed convenient until Lena joined as a freelance photographer for the Riverside festival.
Lena needs to upload festival photos and correct captions. The administrator setting would also let her approve publication and delete other people's work. The reader setting would prevent her doing the job. Theo cannot solve that problem by choosing the more generous label.
A permission names an action the service can allow or refuse. Uploading and approving become separate decisions, so Theo can grant one without granting the other. The list of every permission a service knows is its permission catalog, and its practical value is that it gives people meaningful choices about access.
Lena's job needs exactly two actions: uploading photos and correcting captions. Approving publication, deleting photos and assigning access all stay out of her grant. Which photos she may touch is a separate question that no permission name can answer, and her grant will later be limited to the festival album.
Actions on resource types
The Gazette uses names such as photo.upload and album.share. Each names an action on a kind of resource: the part before the dot is the kind of thing, the part after it is what is done to it. A name tied to a screen, such as upload_page, is less useful: an application can upload through an APIAn application programming interface: a defined way for software to interact with a service. A web API offers endpoints where other programs send HTTP requests. too, and one screen can offer several actions.
| Work to do | Permission |
|---|---|
| Browse photo details | photo.view |
| Download a full-resolution file | photo.download |
| Upload assignment photos | photo.upload |
| Correct captions and keywords | photo.edit_caption |
| Change license terms and credits | photo.edit_rights |
| Approve publication | photo.approve |
| Delete a photo | photo.delete |
| Place or lift a legal hold | photo.place_hold |
| Create an album | album.create |
| Share an album | album.share |
| Edit a role's permissions | role.edit |
| Assign a role to a person | role.assign |
Granularity means how much work one permission covers. A single photo.manage would still give Lena too much. A separate permission for every caption-formatting option would bury Theo in choices nobody makes separately. The useful question is whether the organization needs to grant the actions to different people.
The Gazette keeps captions and keywords together because the same people edit both. Rights information gets its own permission because fewer people should change a license agreement. Editing a role and assigning it are separate too: designing a bundle of access is a different responsibility from deciding who receives it.
A catalog only names decisions. Adding photo.download to it does not protect a single file until the code that serves the download asks whether the caller holds it.
Checking permissions, not titles
A role bundles permissions under one name, so Theo can give a group of people the same set at once. An editor role might contain viewing and approving. The service should ask, "May this person approve this photo?" rather than rely on a role's name. Theo can then change what a role includes without changing the name or rewriting every place that uses it.
Omar edits sports photos but only browses news photos. A title such as "editor" cannot describe both situations by itself. An access decision needs the authenticated person, the requested action and the actual resource, the same parts Deciding what someone can do named. The server loads the photo and checks its album; it does not trust a browser to nominate a different person or claim that any photo belongs to the festival.
Permissions also need an enforcement point, the place in the service where the decision is actually made. Hiding an Approve button makes the interface clearer for Lena, but a direct request must receive the same refusal. The check belongs where the service performs the action, using the person's current assignments and the relevant resource, so a page that was loaded before Theo changed her access cannot carry the old access forward.
For builders Compare a title check with an action check
This illustrative TypeScript assumes the request is authenticated and the service has loaded the photo. The access function must evaluate current grants and resource scope; its name alone supplies no protection.
// A title check embeds the role's meaning in this route.
if (user.role === 'editor') await approve(photo);
// An action check lets the role catalog change independently.
if (!can(user, 'photo.approve', photo)) return refused();
await approve(photo);A delegated client has another boundary: the access granted to that application, which Grants, scopes, and consent explained. Passing the client check does not replace checking the person's access to this photo.
Denying by default
Default deny starts every decision with no access. A valid grant for this person, action and resource can produce a permit. When Lena asks to delete a festival photo, no such grant exists, so the answer stays no.
An unknown permission must also be refused. If a developer misspells photo.approve, treating the unknown name as unrestricted would silently open approval. Refusing the request makes the mistake visible without granting unintended access.
Correct a caption
- Permission checked
- photo.edit_caption
- In the catalog
- Yes
- In Lena's grant
- Yes
Allowed
Approve a photo
- Permission checked
- photo.approve
- In the catalog
- Yes
- In Lena's grant
- No
Refused
A misspelled check
- Permission checked
- photo.aprove
- In the catalog
- No
- In Lena's grant
- No
Refused
Default deny starts every decision with no access.
A service that cannot finish the decision must not perform the protected action. This is failing closed. A policy-store outage and an ordinary denial can both prevent access, but their diagnostic reasons should stay distinct so a support team knows which one needs repair.
For builders Keep an error from turning into permission
function can(user, permission, photo) {
if (!knownPermissions.has(permission)) return false;
try {
return currentGrantAllows(user, permission, photo);
} catch {
recordDecisionFailure(user.id, permission, photo.id);
return false;
}
}Production code also distinguishes unavailable decisions from business denials in safe diagnostics. Do not log a session cookieA small value that a website asks the browser to store and send back with later matching requests. Cookies commonly carry a session identifier, so the site can recognize an ongoing sign-in without your password. or tokenA piece of data issued by a trusted service that a client presents as a credential, for example to call an API or to report a sign-in. Some tokens carry readable claims; others are random strings that only the issuer can interpret. to explain a refusal.
With these checks in place, Lena can correct the caption on a festival photo and is refused when she tries to approve it.
Check your understanding
Try these questions before moving on. If an answer isn't right, use the feedback and try again.
Try it in the Lab
- Choose permissions from a real help-desk taskBuild a role from a short task list, justify what it leaves out, and see the server refuse an unlock sent from a page loaded while the role still applied.
Try a Capture the Flag challenge
Apply this lesson against an isolated, intentionally vulnerable application. Capture a flag, explain the mistake, then repair and retest it.