Access Control and Privacy Settings
You'll learn how to design flexible visibility modes and access controls that let Pastebin users decide exactly who can view their content.
The Core Challenge
Not all pastes should be public. Users need granular control over who accesses their content—from completely open sharing to locked-down private documents. This requires designing multiple visibility tiers with corresponding enforcement mechanisms at every system layer.
Three Primary Visibility Modes
Public pastes are indexed, searchable, and accessible to anyone with the URL. These flow through CDN caching without restrictions.
Unlisted pastes are accessible to anyone with the URL, but aren't indexed or listed in user profiles. Think of them as "secret links"—no authentication required, but discovery requires knowing the exact URL. These still leverage CDN but skip indexing pipelines.
Private pastes require authentication. Only the owner (and optionally, users on an access control list) can view them. These bypass CDN entirely, forcing authenticated database lookups.
Password Protection Layer
Add optional password protection on top of any visibility mode. When retrieving a password-protected paste, the system:
- Checks visibility mode first
- Prompts for password before content delivery
- Validates against a hashed password stored in paste metadata
- Returns content only after successful verification
Access Control Lists (ACLs)
For private pastes, store an ACL as a separate table: paste_id, user_id, permission_level (read/write). Before serving content, query the ACL to verify the requesting user has appropriate permissions. This enables collaborative private documents.
Enforcement Points
Implement checks at the API gateway (earliest rejection), application layer (business logic), and add visibility flags to database queries to prevent accidental leaks through analytics or search features.
Key Takeaway: Design visibility as a spectrum—public, unlisted, and private modes with optional password protection and ACLs—enforced consistently across retrieval, caching, and indexing paths.