forked from openstack/nova
-
Notifications
You must be signed in to change notification settings - Fork 2
Added the _check_role method to the Brain, making role matching explicit. is_admin causes user to have all roles. #9
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
Open
joshuamckenty
wants to merge
21
commits into
cloudbuilders:policy
Choose a base branch
from
joshuamckenty:policy
base: policy
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 18 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
0e23aa6
clean it up yo
vishvananda 0c49c3b
Fixed tests
joshuamckenty 4ee0a33
Fixed tests
joshuamckenty de3e63e
Post to pastebin instead of google.com
joshuamckenty 12543fa
Fail out on missing actions
joshuamckenty 19ad59d
fix tests
vishvananda 892eb95
Merge remote-tracking branch 'josh/policy' into policy
vishvananda eeea292
Early exit tests for both OR and AND
joshuamckenty 2026d51
Stubout urlib and fix the remote call
vishvananda 2c004f5
Merged in vish code.
joshuamckenty 0910aba
Merging vish's http stuff.
joshuamckenty f9a1280
Getting rid of old test.
joshuamckenty 26b6f3c
modify rules to reload on mtime and use inline rules for test
vishvananda d3eb991
Make role-checking rules in policy.py unique - is_admin is equivalent…
joshuamckenty db908d5
Merged Vish's latest
joshuamckenty 522d6a8
Admin user has all roles.
joshuamckenty 0a5ff4c
Rolled out the is_admin use, using admin role instead.
joshuamckenty 26c01f4
add tests for mtime
vishvananda 5103356
Added policy.enforce calls to instance creation, with simple default …
joshuamckenty 0dbfb6d
Use a fake policy.json to allow all actions in other tests
joshuamckenty a493d74
add reset command to policy
vishvananda File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,11 @@ | ||
| { | ||
| 'compute:get_volume': ('role:compute_admin', ('tenant_id:%(tenant_id)s', 'role:compute_sysadmin')), | ||
| 'compute:get_instance': ('role:compute_admin', ('tenant_id:%(tenant_id)s', 'role:compute_sysadmin')), | ||
| 'example:get_google': (('http:http://www.google.com',), ('role:compute_sysadmin',)), | ||
| 'example:my_file': ('role:compute_admin', ('tenant_id:%(tenant_id)s',)) | ||
| 'example:allowed' : (), | ||
| 'example:denied' : ('false:false',), | ||
| } | ||
| "true" : [], | ||
| "compute:create_instance" : [["role:admin"], ["project_id:%(project_id)s"]], | ||
| "compute:attach_network" : [["role:admin"], ["project_id:%(project_id)s"]], | ||
| "compute:attach_volume" : [["role:admin"], ["project_id:%(project_id)s"]], | ||
| "compute:list_instances": [["role:admin"], ["project_id:%(project_id)s"]], | ||
| "compute:get_instance": [["role:admin"], ["project_id:%(project_id)s"]], | ||
| "network:attach_network" : [["role:admin"], ["project_id:%(project_id)s"]], | ||
| "volume:create_volume": [["role:admin"], ["project_id:%(project_id)s"]], | ||
| "volume:attach_volume": [["role:admin"], ["project_id:%(project_id)s"]] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| roles: | ||
| - 'netadmin' | ||
| - 'sysadmin' | ||
| - 'admin' | ||
| - 'member' | ||
| - 'keystoneadmin' | ||
| - 'keystoneserviceadmin' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,6 +29,7 @@ | |
| import nova.image | ||
| from nova import log as logging | ||
| from nova import network | ||
| from nova import policy | ||
| from nova import quota | ||
| from nova import rpc | ||
| from nova import utils | ||
|
|
@@ -542,6 +543,20 @@ def create(self, context, instance_type, | |
| could be 'None' or a list of instance dicts depending on if | ||
| we waited for information from the scheduler or not. | ||
| """ | ||
| target = {'project_id' : context.project_id, | ||
| 'user_id' : context.user_id, | ||
| 'availability_zone' : availability_zone} | ||
| policy.enforce(context, "compute:create_instance", target) | ||
|
|
||
| if requested_networks: | ||
| target['requested_networks'] = requested_networks | ||
| policy.enforce(context, "compute:attach_network", target) | ||
| policy.enforce(context, "network:attach_network", target) | ||
|
|
||
| if block_device_mapping: | ||
| target['block_device'] = block_device_mapping | ||
| policy.enforce(context, "compute:attach_volume", target) | ||
| policy.enforce(context, "volume:attach_volume", target) | ||
|
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. ditto |
||
|
|
||
| # We can create the DB entry for the instance here if we're | ||
| # only going to create 1 instance and we're in a single | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I think that this should be be looping through each network and checking network:attach_network with the target set to the specific network