-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add rbac for process, closes #20
- Loading branch information
Showing
11 changed files
with
177 additions
and
24 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
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
18 changes: 18 additions & 0 deletions
18
prisma/migrations/20240930165111_add_acl_to_process/migration.sql
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,18 @@ | ||
-- RedefineTables | ||
PRAGMA defer_foreign_keys=ON; | ||
PRAGMA foreign_keys=OFF; | ||
CREATE TABLE "new_Process" ( | ||
"id" TEXT NOT NULL PRIMARY KEY, | ||
"body" TEXT NOT NULL, | ||
"title" TEXT NOT NULL, | ||
"complete" BOOLEAN NOT NULL DEFAULT false, | ||
"aclId" TEXT NOT NULL DEFAULT '', | ||
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"updatedAt" DATETIME NOT NULL, | ||
CONSTRAINT "Process_aclId_fkey" FOREIGN KEY ("aclId") REFERENCES "ACL" ("id") ON DELETE RESTRICT ON UPDATE CASCADE | ||
); | ||
INSERT INTO "new_Process" ("body", "complete", "createdAt", "id", "title", "updatedAt") SELECT "body", "complete", "createdAt", "id", "title", "updatedAt" FROM "Process"; | ||
DROP TABLE "Process"; | ||
ALTER TABLE "new_Process" RENAME TO "Process"; | ||
PRAGMA foreign_keys=ON; | ||
PRAGMA defer_foreign_keys=OFF; |
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,16 @@ | ||
-- @param {String} $1:userRole The role of the current user | ||
-- @param {String} $2:userId The ID of the current user | ||
SELECT | ||
Document.id, Document.title, Document.updatedAt | ||
FROM | ||
Document | ||
WHERE | ||
aclId IN (SELECT aclId FROM ACLEntry | ||
WHERE read = true AND ( | ||
(type = "role" AND target = $1) | ||
OR | ||
(type = "user" AND target = $2) | ||
) | ||
) | ||
ORDER BY | ||
Document.title ASC |
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,16 @@ | ||
-- @param {String} $1:userRole The role of the current user | ||
-- @param {String} $2:userId The ID of the current user | ||
SELECT | ||
Process.id, Process.title, Process.updatedAt, Process.complete | ||
FROM | ||
Process | ||
WHERE | ||
aclId IN (SELECT aclId FROM ACLEntry | ||
WHERE read = true AND ( | ||
(type = "role" AND target = $1) | ||
OR | ||
(type = "user" AND target = $2) | ||
) | ||
) | ||
ORDER BY | ||
Process.title ASC |