-
Notifications
You must be signed in to change notification settings - Fork 0
/
statements.go
67 lines (60 loc) · 1.17 KB
/
statements.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package permission
// Placeholders:
// $1 - userID
// $2 - 'system.Authenticated'
// $3 - 'system.Everyone'
const sqlGetUserPrincipals = `
SELECT user_id, principal
FROM permission_principals
WHERE user_id IN ($1, $2, $3)
`
// Placeholders:
// $1 - path
// $2 - perm
const sqlGetACEPrincipals = `
SELECT principal
FROM permission_paths
WHERE path = $1
AND permission = $2
`
// Placeholders:
// $1 - path
// $2 - perm
const sqlMatchACEPrincipals = `
SELECT principal
FROM permission_paths
WHERE path LIKE $1
AND permission = $2
`
// Placeholders:
// $1 - path
// $2 - perm
// $3 - principal
const sqlInsertACE = `
INSERT INTO permission_paths (path, permission, principal)
VALUES ($1, $2, $3)
ON CONFLICT (path, permission, principal) DO NOTHING
`
// Placeholders:
// $1 - path
// $2 - perm
// $3 - principal
const sqlDeleteACE = `
DELETE FROM permission_paths
WHERE path = $1
AND permission = $2
AND principal = $3
`
// Placeholders:
// $1 - path
const sqlGetPerms = `
SELECT permission, principal
FROM permission_paths
WHERE path = $1
`
// Placeholders:
// $1 - path
// const sqlDeletePerms = `
// DELETE FROM permission_paths
// WHERE path = ANY($1)
// `