Social Network
This example presents an Instagram Authorization Schema, outlining the intricate relationships between users, accounts, and posts on the platform. It defines user access levels, privacy settings, and interactions, offering insights into how followers, account owners, and post restrictions are managed within the Instagram ecosystem.
Schema | Open in playground
Brief Examination of the Model
The Instagram Authorization Schema models the relationships between users, accounts, and posts in the Instagram platform.
Users can own accounts, follow other accounts, and be followed by other users. Accounts can have public or private settings, and access to view an account is determined by ownership, followers, and privacy settings. Posts are associated with accounts and can have restricted comments and likes based on account privacy.
Entities & Relations
-
User
: Represents a user on the Instagram platform. -
Account
: Represents a user account on Instagram. Accounts have owners, followers, and can follow other accounts. -
Post
: Represents a post on Instagram. Posts are linked to accounts and can have restricted comments and likes.
Permissions
Users can view an account if they are the owner, a follower, or if the account is public. Users can comment and like posts if they have access to view the linked account and the post is unrestricted.
Relationships and Attributes
Based on our schema, let’s create some sample relationships to test both our schema and our authorization logic.
Test & Validation
To validate our authorization logic, let’s run some tests on different scenarios using the Instagram Authorization Schema.
Test 1: Checking Account Viewing Permissions
Test 2: Checking Post Viewing Permissions
Test 3: Checking Post Commenting Permissions
Let’s test these access checks in our local with using permify validator. We’ll use the below schema for the schema validation file.
Using Schema Validator in Local
After cloning Permify, open up a new file and copy the schema yaml file content inside. Then, build and run Permify instance using the command make serve
Then run permify validate {path of your schema validation file}
to start the test process.
The validation result according to our example schema validation file:
Need any help ?
This is the end of demonstration of the authorization structure for Facebook groups. To install and implement this see the Set Up Permify section.