mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat: scope allow_list to include resource_type (#19748)
This feature allows the `allow_list` in the scopes to specify the `type`
This commit is contained in:
+17
-1
@@ -182,9 +182,25 @@ func (s Scope) regoValue() ast.Value {
|
||||
if !ok {
|
||||
panic("developer error: role is not an object")
|
||||
}
|
||||
|
||||
terms := make([]*ast.Term, len(s.AllowIDList))
|
||||
for i, v := range s.AllowIDList {
|
||||
terms[i] = ast.NewTerm(ast.NewObject(
|
||||
[2]*ast.Term{
|
||||
ast.StringTerm("type"),
|
||||
ast.StringTerm(v.Type),
|
||||
},
|
||||
[2]*ast.Term{
|
||||
ast.StringTerm("id"),
|
||||
ast.StringTerm(v.ID),
|
||||
},
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
r.Insert(
|
||||
ast.StringTerm("allow_list"),
|
||||
ast.NewTerm(regoSliceString(s.AllowIDList...)),
|
||||
ast.NewTerm(ast.NewArray(terms...)),
|
||||
)
|
||||
return r
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user