Menu

1 / 2

🚦 Authorization Explained Like You're 5

DEV CommunityΒ·Sreekar ReddyΒ·6 months ago
#9BKCmezV
#eli5#security#access#authorization#authentication
Reading 0:00
15s threshold

What you're allowed to do

Day 140 of 149

πŸ‘‰ Full deep-dive with code examples

The Movie Theater Analogy

At a movie theater:

Authentication : Prove you bought a ticket

Authorization : Check if your ticket is for VIP or regular

Authentication = who you are. Authorization = what you can do.

The Difference

Authentication Authorization

WHO are you? WHAT can you do?

Login Access control

Verify identity Check permissions

Role-Based Access Control (RBAC)

Most common approach:

roles = { " admin " : [ " create " , " read " , " update " , " delete " ], " editor " : [ " create " , " read " , " update " ], " viewer " : [ " read " ] }

Enter fullscreen mode

Exit fullscreen mode

Check: Does user's role include this permission?

Real Examples

Google Docs : Owner β†’ Editor β†’ Commenter β†’ Viewer

GitHub : Admin β†’ Write β†’ Read

Your app : Admin β†’ Manager β†’ User

HTTP Status Codes

401 Unauthorized : Not logged in

403 Forbidden : Logged in, but no permission

In One Sentence

Authorization checks if an…

Continue reading β€” create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.