Improve grant validation (#3081)
This adds several relationships into the resource package that are then made use of to improve the grant validation that runs during Parse. By understanding mappings between ID and resource type the validation checks can far better align with actual allowed grant formats so we can find several common misunderstandings before they simply result in an authorization failure. In the future some of these functions could be used in the logic in the actual ACL checks but it's not currently necessary and I don't want to lump that change in with this. Note that the tests have not meaningfully changed, but they _have_ had to be updated because the stricter validation is actually catching issues.
This commit is contained in:
1 parent
ef37369c2b
commit
fc664eb35f
12 files changed
+380
-222
No files matched your search
@@ -50,8 +50,8 @@ func TestFetchActionSetForId(t *testing.T) {
|
||||
|
||||
orgRole := iam.TestRole(t, conn, org.GetPublicId())
|
||||
iam.TestUserRole(t, conn, orgRole.PublicId, token.UserId)
|
||||
iam.TestRoleGrant(t, conn, orgRole.PublicId, "id=foo;actions=read,update")
|
||||
iam.TestRoleGrant(t, conn, orgRole.PublicId, "id=bar;actions=read,update,delete,authorize-session")
|
||||
iam.TestRoleGrant(t, conn, orgRole.PublicId, "id=ttcp_foo;actions=read,update")
|
||||
iam.TestRoleGrant(t, conn, orgRole.PublicId, "id=ttcp_bar;actions=read,update,delete,authorize-session")
|
||||
iam.TestRoleGrant(t, conn, orgRole.PublicId, "id=*;type=role;actions=add-grants,remove-grants")
|
||||
|
||||
cases := []struct {
|
||||
@@ -71,7 +71,7 @@ func TestFetchActionSetForId(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "disjoint match",
|
||||
id: "bar",
|
||||
id: "ttcp_bar",
|
||||
avail: action.ActionSet{action.Delete, action.AddGrants, action.Read, action.RemoveHostSets},
|
||||
allowed: action.ActionSet{action.Delete, action.Read},
|
||||
},
|
||||
@@ -107,7 +107,7 @@ func TestFetchActionSetForId(t *testing.T) {
|
||||
typ = tt.typeOverride
|
||||
}
|
||||
res := auth.Verify(ctx, []auth.Option{
|
||||
auth.WithId("foo"),
|
||||
auth.WithId("ttcp_foo"),
|
||||
auth.WithAction(action.Read),
|
||||
auth.WithScopeId(org.PublicId),
|
||||
auth.WithType(typ),
|
||||
|
||||
Reference in new issue
Block a user