Skip to content

Instantly share code, notes, and snippets.

@dsandip
Last active June 9, 2022 16:58
Show Gist options
  • Save dsandip/9746ad1bc36eeca2a264c7c4248390de to your computer and use it in GitHub Desktop.
Save dsandip/9746ad1bc36eeca2a264c7c4248390de to your computer and use it in GitHub Desktop.

Slack permissions model based authorization task

  1. Create a Postgres schema that models a Slack-like app's DB requirements:

    a) There are channels and users(3 user roles: users, moderators, admins).

    b) Users can access a subset of all channels, and create messages in each/any of these accessible channels. They can also modify(edit/delete) their own messages. Any user who belongs to a channel can read all messages in that channel.

    c) Moderators can access a subset of all channels and can access/edit/delete any messages in these channels.

    d) Admins are the kings of this jungle! They can do whatever they want. Admins can create users with the right role.

    e) In summary, there are 3 user roles with the following permission requirements:

    i) Users: can perform CRUD operations on their own messages in the channels they can access.
    
    ii) Moderators: can perform CRUD operations on any messages in the channels they can access.
    
    iii) Admins: can perform CRUD operations on any message in any channel & create users.
    
  2. Set up Hasura roles and permissions to allow the above access patterns. Reference reading: basics of Hasura Authz and common access control patterns.

  3. Please feel free to make any assumptions to keep the modelling as simple as possible (no threads, 1 role per user, etc.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment