-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[a2-694] Add policy for applications service IAM v1 and v2 #462
Changes from all commits
3a9da67
7c7959a
7a0b296
ce1d770
43ace07
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,44 +18,42 @@ import "api/external/common/query/parameters.proto"; | |
service ApplicationsService { | ||
rpc GetServiceGroups(ServiceGroupsReq) returns (ServiceGroups) { | ||
option (google.api.http).get = "/beta/applications/service-groups"; | ||
// TODO (dan, 2/2019): need to replace this once we have resources and such | ||
// created in the auth system | ||
option (chef.automate.api.policy) = { | ||
resource: "nodes" | ||
resource: "service_groups" | ||
action: "list" | ||
}; | ||
option (chef.automate.api.iam.policy) = { | ||
resource: "infra:nodes" | ||
action: "infra:nodes:list" | ||
resource: "applications:serviceGroups" | ||
action: "applications:serviceGroups:list" | ||
}; | ||
}; | ||
rpc GetServiceGroupsHealthCounts(ServiceGroupsHealthCountsReq) returns (HealthCounts) { | ||
// TODO (afiune, 3/2019): need to replace this once we have resources and such | ||
// created in the auth system | ||
option (google.api.http).get = "/beta/applications/service_groups_health_counts"; | ||
option (chef.automate.api.policy).resource = "nodes"; | ||
option (chef.automate.api.policy).resource = "service_groups"; | ||
option (chef.automate.api.policy).action = "list"; | ||
option (chef.automate.api.iam.policy).resource = "infra:nodes"; | ||
option (chef.automate.api.iam.policy).action = "infra:nodes:list"; | ||
option (chef.automate.api.iam.policy).resource = "applications:serviceGroups"; | ||
option (chef.automate.api.iam.policy).action = "applications:serviceGroups:list"; | ||
}; | ||
rpc GetServices(ServicesReq) returns (ServicesRes) { | ||
// TODO (afiune, 4/2019): need to replace this once we have resources and such | ||
// created in the auth system | ||
option (google.api.http).get = "/beta/applications/services"; | ||
option (chef.automate.api.policy).resource = "nodes"; | ||
option (chef.automate.api.policy).resource = "service_groups"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this endpoint has anything to do with service-groups here. This is only listing all services so we would probably need a different resource? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For any future readers of this, we decided to stick with |
||
option (chef.automate.api.policy).action = "list"; | ||
option (chef.automate.api.iam.policy).resource = "infra:nodes"; | ||
option (chef.automate.api.iam.policy).action = "infra:nodes:list"; | ||
option (chef.automate.api.iam.policy).resource = "applications:serviceGroups"; | ||
option (chef.automate.api.iam.policy).action = "applications:serviceGroups:list"; | ||
}; | ||
|
||
rpc GetServicesBySG(ServicesBySGReq) returns (ServicesBySGRes) { | ||
// TODO (afiune, 4/2019): need to replace this once we have resources and such | ||
// created in the auth system | ||
option (google.api.http).get = "/beta/applications/service-groups/{service_group_id}"; | ||
option (chef.automate.api.policy).resource = "nodes"; | ||
option (chef.automate.api.policy).resource = "service_groups"; | ||
option (chef.automate.api.policy).action = "list"; | ||
option (chef.automate.api.iam.policy).resource = "infra:nodes"; | ||
option (chef.automate.api.iam.policy).action = "infra:nodes:list"; | ||
option (chef.automate.api.iam.policy).resource = "applications:serviceGroups"; | ||
option (chef.automate.api.iam.policy).action = "applications:serviceGroups:list"; | ||
}; | ||
rpc GetVersion (common.version.VersionInfoRequest) returns (common.version.VersionInfo) { | ||
option (google.api.http).get = "/beta/applications/version"; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
BEGIN; | ||
|
||
UPDATE iam_roles | ||
SET | ||
actions = actions || '{applications:*:list, applications:*:get}' | ||
WHERE | ||
id = 'viewer'; | ||
|
||
UPDATE iam_roles | ||
SET | ||
actions = actions || '{applications:*}' | ||
WHERE | ||
id = 'editor'; | ||
|
||
COMMIT; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
BEGIN; | ||
|
||
INSERT INTO policies | ||
VALUES ('aee14d59-da0b-4974-ba6d-1a018b024874', | ||
'{"action": "*", "effect": "allow", "resource": "service_groups", "subjects": ["user:*"]}', | ||
CURRENT_TIMESTAMP, | ||
1, | ||
TRUE) | ||
ON CONFLICT (id) DO UPDATE | ||
SET policy_data='{"action": "*", "effect": "allow", "resource": "service_groups", "subjects": ["user:*"]}', | ||
deletable=TRUE; | ||
|
||
COMMIT; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -300,6 +300,14 @@ func DefaultPolicies() (map[string]*Policy, error) { | |
Effect: "allow", | ||
Version: 1, | ||
}, | ||
constants.ApplicationsServiceGroupsPolicyID: { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You've added this policy to our system policies, which are hidden policies that govern permissions that Automate needs to work correctly (i.e. every user always needs to be able to get the license status so they won't be always blocked by the license modal). These policies never change. My guess is that we should be able to change permissions on this API. In that case, instead of adding this policy, we'll want to add the API's v2 action to the role(s) that should have access. Maybe Viewer and Editor? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. actually just kidding about that system policy comment! i misread the code. this is correct for adding a v1 default policy π for v2 permissions:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we make changes to these roles please also update the iam v2 docs, thx! |
||
ID: ids[constants.ApplicationsServiceGroupsPolicyID], | ||
Subjects: []string{"user:*"}, | ||
Resource: "service_groups", | ||
Action: "*", | ||
Effect: "allow", | ||
Version: 1, | ||
}, | ||
} | ||
return defaultPolicies, nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you can GetServices, can you always get their healthcounts and get services by SG?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, at least you should be able to.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gotcha, makes sense that all the resources/actions should be the same then. π