This repository has been archived by the owner on Sep 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ENHANCEMENT]: Implement Access Validation
- Loading branch information
Showing
7 changed files
with
667 additions
and
40 deletions.
There are no files selected for viewing
This file contains 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 characters
This file contains 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 characters
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import:py from jaclang.runtimelib.architype {Anchor} | ||
import:py from uuid {UUID} | ||
|
||
node A { | ||
has val: int; | ||
} | ||
|
||
walker check_node { | ||
can enter with `root entry { | ||
visit [-->]; | ||
} | ||
|
||
can enter2 with A entry { | ||
print(here); | ||
} | ||
} | ||
|
||
walker update_node { | ||
has val: int; | ||
|
||
can enter2 with A entry { | ||
here.val = self.val; | ||
} | ||
} | ||
|
||
walker create_node { | ||
has val: int; | ||
|
||
can enter with `root entry { | ||
a = A(val=self.val); | ||
here ++> a; | ||
print(a.__jac__.id); | ||
} | ||
} | ||
|
||
walker create_other_root { | ||
can enter with `root entry { | ||
other_root = `root().__jac__; | ||
other_root.save(); | ||
print(other_root.id); | ||
} | ||
} | ||
|
||
walker allow_other_root_access { | ||
has root_id: str, level: int | str = 1, via_all: bool = False; | ||
|
||
can enter_root with `root entry { | ||
if self.via_all { | ||
here.__jac__.unrestrict(self.level); | ||
} else { | ||
here.__jac__.allow_root(UUID(self.root_id), self.level); | ||
} | ||
} | ||
|
||
can enter_nested with A entry { | ||
if self.via_all { | ||
here.__jac__.unrestrict(self.level); | ||
} else { | ||
here.__jac__.allow_root(UUID(self.root_id), self.level); | ||
} | ||
} | ||
} | ||
|
||
walker disallow_other_root_access { | ||
has root_id: str, via_all: bool = False; | ||
|
||
can enter_root with `root entry { | ||
if self.via_all { | ||
here.__jac__.restrict(); | ||
} else { | ||
here.__jac__.disallow_root(UUID(self.root_id)); | ||
} | ||
} | ||
|
||
can enter_nested with A entry { | ||
if self.via_all { | ||
here.__jac__.restrict(); | ||
} else { | ||
here.__jac__.disallow_root(UUID(self.root_id)); | ||
} | ||
} | ||
} |
Oops, something went wrong.