Access control: Load permissions from memory and database (#42080)
* Load permission from both in memory and from database Co-authored-by: Gabriel MABILLE <gamab@users.noreply.github.com>
This commit is contained in:
@@ -37,6 +37,17 @@ func (s *AccessControlStore) GetUserPermissions(ctx context.Context, query acces
|
||||
INNER JOIN role ON role.id = permission.role_id
|
||||
` + filter
|
||||
|
||||
if query.Actions != nil {
|
||||
q += " AND permission.action IN("
|
||||
if len(query.Actions) > 0 {
|
||||
q += "?" + strings.Repeat(",?", len(query.Actions)-1)
|
||||
}
|
||||
q += ")"
|
||||
for _, a := range query.Actions {
|
||||
params = append(params, a)
|
||||
}
|
||||
}
|
||||
|
||||
if err := sess.SQL(q, params...).Find(&result); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user