DEV Community

Cover image for TrailerTime - Permissions Redefined
Syed Nahida Anjum
Syed Nahida Anjum

Posted on

TrailerTime - Permissions Redefined

This is a submission for the Permit.io Authorization Challenge: Permissions Redefined

๐ŸŽฌ TrailerTime

Watch. Manage. Control Trailers Like a Pro.

A submission for the Permit.io Authorization Challenge: Permissions Redefined

"What if Netflix had a little sibling who only cared about trailers, and also had an overprotective parent (aka Permit.io) deciding who gets to press which button?"

Well, meet TrailerTime โ€” my entry to the Permissions Redefined Challenge by Permit.io.


๐Ÿ”— Table of Contents


๐Ÿฟ What is TrailerTime?

๐ŸŽ‰ TrailerTime is a web app that lets users view a curated list of movie trailers โ€” think Netflix, but no sign-ups, no streaming, and no ex-boyfriends calling mid-show.

Itโ€™s focused, clean, and smartly protected with role-based access control using Permit.io.

But hereโ€™s the twist: Not all users get to wear the Editorโ€™s cape or wield the mighty Delete buttonโ€”not everyone gets the keys to the kingdom.

Using Permit.io, I baked in fine-grained role-based access control so that Admins, Editors, and Users each see a different experience. No more accidental trailer deletions by your curious cousin.


๐Ÿ” Why Authorization Matters

Ever had a friend "borrow" your Netflix and mess up your watchlist?

Yeah, now imagine they could also delete movies. ๐ŸŽฌ๐Ÿ’ฅ

That's why authorization isnโ€™t just a backend problemโ€”it's a user experience decision.

With Permit.io, I avoided spaghetti authorization code and instead used policy-as-code. Clean, scalable, and secure. Just how modern apps should be.


๐Ÿ‘ฅ Roles & Permissions

Role Create Read Update Delete Vibes
Admin โœ… โœ… โœ… โœ… The boss. Has all the buttons.
Editor โœ… โœ… โœ… โŒ Trusted sidekick. No delete.
User โŒ โœ… โŒ โŒ Just here for food & trailers.

The frontend reacts to the user's role and dynamically shows/hides buttons like Create, Edit, and Delete.

The backend uses Permit.io's middleware to authorize API requests, ensuring no one sneaks into the editing room uninvited.

The UI and API both respect this table like itโ€™s the law. Because it kinda is.


๐ŸŽฅ Demo & Screenshots

While it's not deployed (YET), here's what you can look forward to:

๐Ÿ”— Video Demo on Loom

Application Demo Overview ๐Ÿš€ - Watch Video

๐Ÿ“ธ Screenshots:

๐Ÿ  Login Page with Trailers

Login page

๐Ÿ› ๏ธ Admin Dashboard

Add, Edit, Delete all the things.

Admin

โœ๏ธ Editor View

You can edit, but you canโ€™t delete. Sorry, editors.

Editor

๐Ÿ‘€ User View

Pure read-only bliss.

user

Permit policy:
permitpolicy

Permit integration:
permit dashboard


๐Ÿ’ป Project Repo

๐Ÿ‘‰ GitHub: TrailerTime Repo

Everythingโ€™s open-source, from the React frontend to the Express backend. Cleanly structured, well-documented, and ready for feedback!


๐Ÿ› ๏ธ How I Built It

๐Ÿง  The Idea:

  • Netflix-style UI but permission-aware
  • Auth with Permit.io โ€“ because DIY auth logic is a dark path
  • Frontend: React
  • Backend: Node.js + Express
  • Database: Sqlite
  • Authz: Permit.io

๐Ÿ› ๏ธ How I Used Permit.io

๐ŸŽฏ Zero CLI, 100% middleware magic.

Since I didnโ€™t use the CLI, all permission checks were baked into the app using Permit.io's Node.js and React SDKs.

๐Ÿ”’ Backend Authorization

I used Permit.io's middleware in Express to protect routes:

const { Permit } = require('permitio');
const permit = new Permit({ pdp: "https://cloudpdp.api.permit.io", token: process.env.PERMIT_API_KEY });

const checkPermission = async (req, res, next) => {
  const allowed = await permit.check(req.user.id, 'trailer:create');
  if (!allowed) return res.status(403).json({ error: 'Unauthorized' });
  next();
};
Enter fullscreen mode Exit fullscreen mode
  • โœ… Keeps backend logic clean
  • โœ… No more hardcoded roles
  • โœ… Centralized access control

๐ŸŽจ Frontend Logic

Permit.io's SDK helped me render UI conditionally:

import { useCheck } from '@permitio/react-access-control';

const { loading, result } = useCheck('trailer:create');

return !loading && result ? <button>Add Trailer</button> : null;
Enter fullscreen mode Exit fullscreen mode

๐Ÿคฉ This way, Users only see buttons theyโ€™re allowed to click.

๐Ÿคฏ Challenges Faced

Challenge Reaction Resolution
Learning Permit.io for the first time ๐Ÿคฏ Read docs, broke stuff, fixed stuff
Conditional rendering based on roles ๐Ÿ˜ต Used Permit.ioโ€™s SDK in React smartly
Styling under a time crunch ๐Ÿซ  Focused on function first, polish second

๐Ÿ˜… Fun, Fails & Fixes

๐Ÿ” "Why is the Delete button showing for Users?"

Turns out, I forgot to wrap the permission check around a button. Frontend users are sneaky!

โณ Time pressure meant sacrificing a fancier UI for solid security.

Would I love a slicker design? Yes.

Would I prefer to sleep this week? Also yes.

๐Ÿคน Learning Permit.io as a first-timer was funโ€”especially when docs saved me from inventing my own RBAC system.

  • Used React SDK to control UI elements.
  • Want the "Delete" button? Better be an admin.
  • Backend uses middleware checks to validate every action against Permit.io's policy.
  • Policy-as-code helped me version-control my permissions. Git diff > digging through auth logic spaghetti.

๐Ÿ’ฌ Final Thoughts

Building TrailerTime was a blast ๐ŸŽ†โ€”and a serious learning experience. Here's what I walked away with:

  • โœ… Role-based access is more than a backend checkbox.
  • โœ… Permit.io lets you move fast without breaking permissions.
  • โœ… Policy-as-code is scalable, readable, and GitHub-approved.
  • โœ… UI/UX and security can be friends. Who knew?
  • โœ… Would I use it in a real production app? Absolutely.
  • โœ… Would I recommend it to teams struggling with access control? 100%.

๐Ÿค Permit.io Team: Feedback Welcome!

Iโ€™d love it if this submission helps:

  • Educate newcomers on integrating Permit.io in full-stack apps
  • Inspire additions to the Permit.io docs or examples
  • Start a conversation around best practices in frontend-backend authz integration

๐Ÿ“ฃ Shoutout

I would like to thank my friend and saviour Aamir Kalimi, because sometimes you need someone else to look at your code to find out your silly, stupid mistakes ๐Ÿ˜‚

If you're ever hiring a trailer-loving, RBAC-obsessed developer โ€” I'm available ๐Ÿ˜„

Also, feel free to feature this in your docs (just send me the swag ๐Ÿ‘•๐Ÿ˜‰).

To the Permit.io teamโ€”thank you for simplifying something thatโ€™s usually a pain to get right. With tools like this, even solo devs like me can build secure, scalable apps in a hackathon timeline โœจ

๐Ÿ‘‹ Want to Connect?

If you found this helpful or interesting, give it a โค๏ธ or drop a comment. Iโ€™d love feedback!

Top comments (0)