1
0
Fork 0
mirror of https://github.com/binwiederhier/ntfy.git synced 2024-12-23 02:02:33 +01:00

user.Manager: further improve ACL write/read order

For each user, we should test in order `THE_LONGEST_RULE`->`WRITE_PERMISSION`
This commit is contained in:
Nikolay Zlatev 2023-10-16 09:41:49 +03:00
parent 5c9cebf059
commit 7a5572ad7c

View file

@ -161,7 +161,7 @@ const (
FROM user_access a
JOIN user u ON u.id = a.user_id
WHERE (u.user = ? OR u.user = ?) AND ? LIKE a.topic ESCAPE '\'
ORDER BY u.user DESC, a.write DESC
ORDER BY u.user DESC, LENGTH(a.topic) DESC, a.write DESC
`
insertUserQuery = `
@ -197,13 +197,13 @@ const (
selectUserAllAccessQuery = `
SELECT user_id, topic, read, write
FROM user_access
ORDER BY write DESC, read DESC, topic
ORDER BY LENGTH(topic) DESC, write DESC, read DESC, topic
`
selectUserAccessQuery = `
SELECT topic, read, write
FROM user_access
WHERE user_id = (SELECT id FROM user WHERE user = ?)
ORDER BY write DESC, read DESC, topic
ORDER BY LENGTH(topic) DESC, write DESC, read DESC, topic
`
selectUserReservationsQuery = `
SELECT a_user.topic, a_user.read, a_user.write, a_everyone.read AS everyone_read, a_everyone.write AS everyone_write