Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4c25ec6

Browse files
committed
beginnning of a disaster
1 parent8b92f23 commit4c25ec6

File tree

2 files changed

+28
-21
lines changed

2 files changed

+28
-21
lines changed

‎coderd/rbac/astvalue.go‎

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -157,30 +157,37 @@ func (role Role) regoValue() ast.Value {
157157
ifrole.cachedRegoValue!=nil {
158158
returnrole.cachedRegoValue
159159
}
160-
orgMap:=ast.NewObject()
161-
fork,p:=rangerole.Org {
162-
orgMap.Insert(ast.StringTerm(k),ast.NewTerm(regoSlice(p)))
163-
}
164-
orgMemberMap:=ast.NewObject()
165-
fork,p:=rangerole.OrgMember {
166-
orgMemberMap.Insert(ast.StringTerm(k),ast.NewTerm(regoSlice(p)))
160+
byOrgIDMap:=ast.NewObject()
161+
fork,p:=rangerole.ByOrgID {
162+
byOrgIDMap.Insert(ast.StringTerm(k),ast.NewTerm(
163+
ast.NewObject(
164+
[2]*ast.Term{
165+
ast.StringTerm("org"),
166+
ast.NewTerm(regoSlice(p.Org)),
167+
},
168+
),
169+
))
170+
byOrgIDMap.Insert(ast.StringTerm(k),ast.NewTerm(
171+
ast.NewObject(
172+
[2]*ast.Term{
173+
ast.StringTerm("member"),
174+
ast.NewTerm(regoSlice(p.Member)),
175+
},
176+
),
177+
))
167178
}
168179
returnast.NewObject(
169180
[2]*ast.Term{
170181
ast.StringTerm("site"),
171182
ast.NewTerm(regoSlice(role.Site)),
172183
},
173-
[2]*ast.Term{
174-
ast.StringTerm("org"),
175-
ast.NewTerm(orgMap),
176-
},
177184
[2]*ast.Term{
178185
ast.StringTerm("user"),
179186
ast.NewTerm(regoSlice(role.User)),
180187
},
181188
[2]*ast.Term{
182-
ast.StringTerm("org_member"),
183-
ast.NewTerm(orgMemberMap),
189+
ast.StringTerm("by_org_id"),
190+
ast.NewTerm(byOrgIDMap),
184191
},
185192
)
186193
}

‎coderd/rbac/roles.go‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -701,20 +701,20 @@ type Role struct {
701701
DisplayNamestring`json:"display_name"`
702702
Site []Permission`json:"site"`
703703
User []Permission`json:"user"`
704-
ByOrgIDmap[string]struct {
705-
// Org is a map of organization IDs to permissions. Grouping by organization
706-
// makes roles easy to combine.
707-
Org []Permission`json:"org"`
708-
// OrgMember is a map of organization IDs to permissions. Grouping by
709-
// organization makes roles easy to combine.
710-
Member []Permission`json:"member"`
711-
}`json:"by_org_id"`
704+
// Org is a map of organization IDs to permissions. Grouping by organization
705+
// makes roles easy to combine.
706+
ByOrgIDmap[string]RolePermissionsByOrgID`json:"by_org_id"`
712707

713708
// cachedRegoValue can be used to cache the rego value for this role.
714709
// This is helpful for static roles that never change.
715710
cachedRegoValue ast.Value
716711
}
717712

713+
typeRolePermissionsByOrgIDstruct {
714+
Org []Permission`json:"org"`
715+
Member []Permission`json:"member"`
716+
}
717+
718718
// Valid will check all it's permissions and ensure they are all correct
719719
// according to the policy. This verifies every action specified make sense
720720
// for the given resource.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp