You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Descope support full relation based access control (ReBAC) using a zanzibar like schema and operations.
847
+
A schema is comprized of namespaces (entities like documents, folders, orgs, etc.) and each namespace has relation definitions to define relations.
848
+
Each relation definition can be simple (either you have it or not) or complex (union of nodes).
849
+
850
+
A simple example for a file system like schema would be:
851
+
852
+
```yaml
853
+
# Example schema for the authz tests
854
+
name: Files
855
+
namespaces:
856
+
- name: org
857
+
relationDefinitions:
858
+
- name: parent
859
+
- name: member
860
+
complexDefinition:
861
+
nType: union
862
+
children:
863
+
- nType: child
864
+
expression:
865
+
neType: self
866
+
- nType: child
867
+
expression:
868
+
neType: relationLeft
869
+
relationDefinition: parent
870
+
relationDefinitionNamespace: org
871
+
targetRelationDefinition: member
872
+
targetRelationDefinitionNamespace: org
873
+
- name: folder
874
+
relationDefinitions:
875
+
- name: parent
876
+
- name: owner
877
+
complexDefinition:
878
+
nType: union
879
+
children:
880
+
- nType: child
881
+
expression:
882
+
neType: self
883
+
- nType: child
884
+
expression:
885
+
neType: relationRight
886
+
relationDefinition: parent
887
+
relationDefinitionNamespace: folder
888
+
targetRelationDefinition: owner
889
+
targetRelationDefinitionNamespace: folder
890
+
- name: editor
891
+
complexDefinition:
892
+
nType: union
893
+
children:
894
+
- nType: child
895
+
expression:
896
+
neType: self
897
+
- nType: child
898
+
expression:
899
+
neType: relationRight
900
+
relationDefinition: parent
901
+
relationDefinitionNamespace: folder
902
+
targetRelationDefinition: editor
903
+
targetRelationDefinitionNamespace: folder
904
+
- nType: child
905
+
expression:
906
+
neType: targetSet
907
+
targetRelationDefinition: owner
908
+
targetRelationDefinitionNamespace: folder
909
+
- name: viewer
910
+
complexDefinition:
911
+
nType: union
912
+
children:
913
+
- nType: child
914
+
expression:
915
+
neType: self
916
+
- nType: child
917
+
expression:
918
+
neType: relationRight
919
+
relationDefinition: parent
920
+
relationDefinitionNamespace: folder
921
+
targetRelationDefinition: viewer
922
+
targetRelationDefinitionNamespace: folder
923
+
- nType: child
924
+
expression:
925
+
neType: targetSet
926
+
targetRelationDefinition: editor
927
+
targetRelationDefinitionNamespace: folder
928
+
- name: doc
929
+
relationDefinitions:
930
+
- name: parent
931
+
- name: owner
932
+
complexDefinition:
933
+
nType: union
934
+
children:
935
+
- nType: child
936
+
expression:
937
+
neType: self
938
+
- nType: child
939
+
expression:
940
+
neType: relationRight
941
+
relationDefinition: parent
942
+
relationDefinitionNamespace: doc
943
+
targetRelationDefinition: owner
944
+
targetRelationDefinitionNamespace: folder
945
+
- name: editor
946
+
complexDefinition:
947
+
nType: union
948
+
children:
949
+
- nType: child
950
+
expression:
951
+
neType: self
952
+
- nType: child
953
+
expression:
954
+
neType: relationRight
955
+
relationDefinition: parent
956
+
relationDefinitionNamespace: doc
957
+
targetRelationDefinition: editor
958
+
targetRelationDefinitionNamespace: folder
959
+
- nType: child
960
+
expression:
961
+
neType: targetSet
962
+
targetRelationDefinition: owner
963
+
targetRelationDefinitionNamespace: doc
964
+
- name: viewer
965
+
complexDefinition:
966
+
nType: union
967
+
children:
968
+
- nType: child
969
+
expression:
970
+
neType: self
971
+
- nType: child
972
+
expression:
973
+
neType: relationRight
974
+
relationDefinition: parent
975
+
relationDefinitionNamespace: doc
976
+
targetRelationDefinition: viewer
977
+
targetRelationDefinitionNamespace: folder
978
+
- nType: child
979
+
expression:
980
+
neType: targetSet
981
+
targetRelationDefinition: editor
982
+
targetRelationDefinitionNamespace: doc
983
+
```
984
+
985
+
Descope SDK allows you to fully manage the schema and relations as well as perform simple (and not so simple) checks regarding the existence of relations.
986
+
987
+
```typescript
988
+
// Load the existing schema
989
+
const s = await descopeClient.management.authz.loadSchema();
990
+
console.log(s);
991
+
992
+
// Save schema and make sure to remove all namespaces not listed
0 commit comments