-
-
Save jeffdev11/dc72a8dc81c99000e2293cc00d06009c to your computer and use it in GitHub Desktop.
Revisions
-
GavinRay97 revised this gist
Mar 26, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -37,7 +37,7 @@ And provision the permissions like such: Now when we query with our `X-Hasura-User-Id` set as User `1` and `3` respectively, we can see only those users in our own organizations: | User ID 1 (Org 1) | User ID 3 (Org 2) | | ---------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- | |  |  | -
GavinRay97 revised this gist
Mar 26, 2020 . 1 changed file with 0 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -27,11 +27,6 @@ We create the following relationships on our data: # Permissions And provision the permissions like such: | User | Organization User | Organization | | ----------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- | -
GavinRay97 revised this gist
Mar 26, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,7 +5,7 @@ This document outlines how to model a common organization-based permission syste | Table Name | Columns | Foreign Keys | |:-----------------:|:---------------------------- | ------------------------------------------------------------------------ | | User | id, name, email | | | Organization User | id, user_id, organization_id | user_id -> user.id, organization_id -> organization.id | | Organization | id, name | | # Example Data -
GavinRay97 revised this gist
Mar 26, 2020 . 1 changed file with 6 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,7 +10,7 @@ This document outlines how to model a common organization-based permission syste # Example Data Here we have example users, two (John and Jane) belonging to Organization ID 1, and Frank belonging to Organization ID 2: | User | Organization User | Organization | | ------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- | @@ -28,9 +28,9 @@ We create the following relationships on our data: And provision the permissions like such: ``` user: {"organization_users":{"organizations":{"organization_users":{"user_id":{"_eq":"X-Hasura-User-Id"}}}}} organization_user: {"organization":{"organization_users":{"user_id":{"_eq":"X-Hasura-User-Id"}}}} organization: {"organization_users":{"user_id":{"_eq":"X-Hasura-User-Id"}}} ``` | User | Organization User | Organization | @@ -40,6 +40,8 @@ organization: {"organization_user":{"user_id":{"\_eq":"X-Hasura-User-Id"}}} # Query Results Now when we query with our `X-Hasura-User-Id` set as User `1` and `3` respectively, we can see only those users in our own organizations: | User ID 1 (Org 1) | User ID 1 (Org 2) | | ---------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- | |  |  | -
GavinRay97 revised this gist
Mar 26, 2020 . 1 changed file with 22 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,17 +1,38 @@ # Introduction This document outlines how to model a common organization-based permission system in Hasura. Let's assume that you have some table structure like the following: | Table Name | Columns | Foreign Keys | |:-----------------:|:---------------------------- | ------------------------------------------------------------------------ | | User | id, name, email | | | Organization User | id, user_id, organization_id | user_id -> user.id organization_id -> organization.id | | Organization | id, name | | # Example Data Here we have example users, two (John and Jane) beloning to Organization ID 1, and Frank belonging to Organization ID 2: | User | Organization User | Organization | | ------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- | |  |  |  | # Relationships We create the following relationships on our data: | User | Organization User | Organization | | ---------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- | |  |  |  | # Permissions And provision the permissions like such: ``` user: {"organization_user":{"organization":{"organization_user":{"user_id":{"\_eq":"X-Hasura-User-Id"}}}}} organization_user: {"organization":{"organization_user":{"user_id":{"\_eq":"X-Hasura-User-Id"}}}} organization: {"organization_user":{"user_id":{"\_eq":"X-Hasura-User-Id"}}} ``` | User | Organization User | Organization | | ----------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- | | | | | @@ -23,6 +44,4 @@ | ---------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- | |  |  | -
GavinRay97 revised this gist
Mar 26, 2020 . 1 changed file with 14 additions and 16 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,30 +1,28 @@ # Example Data | User | Organization User | Organization | | ------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- | |  |  |  | # Relationships | User | Organization User | Organization | | ---------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- | |  |  |  | # Permissions | User | Organization User | Organization | | ----------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- | | | | | |  |  |  | # Query Results | User ID 1 (Org 1) | User ID 1 (Org 2) | | ---------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- | |  |  | user: {"organization_user":{"organization":{"organization_user":{"user_id":{"\_eq":"X-Hasura-User-Id"}}}}} organization_user: {"organization":{"organization_user":{"user_id":{"\_eq":"X-Hasura-User-Id"}}}} organization: {"organization_user":{"user_id":{"\_eq":"X-Hasura-User-Id"}}} -
GavinRay97 revised this gist
Mar 26, 2020 . 1 changed file with 7 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,25 +2,28 @@ | User | Organization User | Organization | | -------------------------------------------- | ------------------------------------------------ | ------------------------------------------- | |  |  |  | # Relationships | User | Organization User | Organization | | ------------------------------------------ | ---------------------------------------------- | ---------------------------------------- | |  |  |  | # Permissions | User | Organization User | Organization | | ------------------------------------- | ----------------------------------------- | ------------------------------------------ | |  |  |  | # Query Results | User ID 1 (Org 1) | User ID 1 (Org 2) | | ------------------------------ | ------------------------------ | |  |  | user: {"organization_user":{"organization":{"organization_user":{"user_id":{"_eq":"X-Hasura-User-Id"}}}}} organization_user: {"organization":{"organization_user":{"user_id":{"_eq":"X-Hasura-User-Id"}}}} -
GavinRay97 created this gist
Mar 26, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,27 @@ # Example Data | User | Organization User | Organization | | -------------------------------------------- | ------------------------------------------------ | ------------------------------------------- | |  |  |  | # Relationships | User | Organization User | Organization | | ------------------------------------------ | ---------------------------------------------- | ---------------------------------------- | |  |  |  | # Permissions | User | Organization User | Organization | | ------------------------------------- | ----------------------------------------- | ------------------------------------------ | |  |  |  | # Query Results | User ID 1 (Org 1) | User ID 1 (Org 2) | | ------------------------------ | ------------------------------ | |  |  | user: {"organization_user":{"organization":{"organization_user":{"user_id":{"_eq":"X-Hasura-User-Id"}}}}} organization_user: {"organization":{"organization_user":{"user_id":{"_eq":"X-Hasura-User-Id"}}}} organization: {"organization_user":{"user_id":{"_eq":"X-Hasura-User-Id"}}}