)]}'
{"/COMMIT_MSG":[{"author":{"_account_id":11564,"name":"Chris Dent","email":"cdent@anticdent.org","username":"chdent"},"change_message_id":"15b9ad166dfce7532e0085e10975ae5510b0b761","unresolved":false,"context_lines":[{"line_number":7,"context_line":"Add policy-remove-scope-checks spec"},{"line_number":8,"context_line":""},{"line_number":9,"context_line":"Here we separate the concerns of what resources user has access to and"},{"line_number":10,"context_line":"what actions the user is allowed to do, but adding a new explicit scope"},{"line_number":11,"context_line":"check alongside the existing policy checks."},{"line_number":12,"context_line":""},{"line_number":13,"context_line":"The current is_admin_or_owner policy is very confusing, it is much"}],"source_content_type":"text/x-gerrit-commit-message","patch_set":21,"id":"dfeb2761_f6c7af11","line":10,"updated":"2017-04-04 11:25:44.000000000","message":"s/but/by/   ?","commit_id":"2ce720bb89fd042e118c62532e2440e1a7369a5a"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"b8d1ab62ce7fbc17e3881dcc016c1a9d6424b1bc","unresolved":false,"context_lines":[{"line_number":7,"context_line":"Add policy-remove-scope-checks spec"},{"line_number":8,"context_line":""},{"line_number":9,"context_line":"Here we separate the concerns of what resources user has access to and"},{"line_number":10,"context_line":"what actions the user is allowed to do, but adding a new explicit scope"},{"line_number":11,"context_line":"check alongside the existing policy checks."},{"line_number":12,"context_line":""},{"line_number":13,"context_line":"The current is_admin_or_owner policy is very confusing, it is much"}],"source_content_type":"text/x-gerrit-commit-message","patch_set":21,"id":"bff0334d_2ca9ca8e","line":10,"in_reply_to":"dfeb2761_f6c7af11","updated":"2017-04-12 23:39:49.000000000","message":"yeah","commit_id":"2ce720bb89fd042e118c62532e2440e1a7369a5a"}],"specs/pike/approved/policy-project-checks.rst":[{"author":{"_account_id":5046,"name":"Lance Bragstad","email":"lbragstad@redhat.com","username":"ldbragst"},"change_message_id":"f7a16793b31e168f0b0334d0774dd0f52cc800dd","unresolved":false,"context_lines":[{"line_number":10,"context_line":""},{"line_number":11,"context_line":"https://blueprints.launchpad.net/nova/+spec/policy-project-checks"},{"line_number":12,"context_line":""},{"line_number":13,"context_line":"The current admin_or_owner policy check is meaningless."},{"line_number":14,"context_line":"This looks at what we replace that with, and how we test it all."},{"line_number":15,"context_line":""},{"line_number":16,"context_line":"Problem description"}],"source_content_type":"text/x-rst","patch_set":6,"id":"fa31d9ce_15f0b3c8","line":13,"updated":"2017-02-14 02:55:29.000000000","message":"The title of this specification implies that `admin_of_owner` is the only policy rule that includes scope?","commit_id":"f7b400bb87f0313cd2b6c382f0f3be6d27779be6"},{"author":{"_account_id":782,"name":"John Garbutt","email":"john@johngarbutt.com","username":"johngarbutt"},"change_message_id":"4663f881f14819fa12ff81d9a8cf2ec8b926e4bf","unresolved":false,"context_lines":[{"line_number":10,"context_line":""},{"line_number":11,"context_line":"https://blueprints.launchpad.net/nova/+spec/policy-project-checks"},{"line_number":12,"context_line":""},{"line_number":13,"context_line":"The current admin_or_owner policy check is meaningless."},{"line_number":14,"context_line":"This looks at what we replace that with, and how we test it all."},{"line_number":15,"context_line":""},{"line_number":16,"context_line":"Problem description"}],"source_content_type":"text/x-rst","patch_set":6,"id":"fa31d9ce_2f3f1825","line":13,"in_reply_to":"fa31d9ce_15f0b3c8","updated":"2017-02-14 09:46:38.000000000","message":"yeah, I should update that one, I renamed after I read the policy file again :)","commit_id":"f7b400bb87f0313cd2b6c382f0f3be6d27779be6"},{"author":{"_account_id":5046,"name":"Lance Bragstad","email":"lbragstad@redhat.com","username":"ldbragst"},"change_message_id":"f7a16793b31e168f0b0334d0774dd0f52cc800dd","unresolved":false,"context_lines":[{"line_number":23,"context_line":""},{"line_number":24,"context_line":""},{"line_number":25,"context_line":"We need to move to there"},{"line_number":26,"context_line":"being no default target. Even there there is no target to specify, we should"},{"line_number":27,"context_line":"explicitly pass a target of {}, to avoid any confusion."},{"line_number":28,"context_line":""},{"line_number":29,"context_line":"The DB layer currently enforces the project membership requirements of each"}],"source_content_type":"text/x-rst","patch_set":6,"id":"fa31d9ce_d5fb7bbf","line":26,"updated":"2017-02-14 02:55:29.000000000","message":"Even if there*","commit_id":"f7b400bb87f0313cd2b6c382f0f3be6d27779be6"},{"author":{"_account_id":5046,"name":"Lance Bragstad","email":"lbragstad@redhat.com","username":"ldbragst"},"change_message_id":"f7a16793b31e168f0b0334d0774dd0f52cc800dd","unresolved":false,"context_lines":[{"line_number":53,"context_line":"Proposed change"},{"line_number":54,"context_line":"\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d"},{"line_number":55,"context_line":""},{"line_number":56,"context_line":"We will be a new policy rule rule added:::"},{"line_number":57,"context_line":""},{"line_number":58,"context_line":"    \"context_is_global_scope\": \"rule:admin_api\""},{"line_number":59,"context_line":""}],"source_content_type":"text/x-rst","patch_set":6,"id":"fa31d9ce_b5b7e7f3","line":56,"updated":"2017-02-14 02:55:29.000000000","message":"There will* \n\ns/rule//","commit_id":"f7b400bb87f0313cd2b6c382f0f3be6d27779be6"},{"author":{"_account_id":5046,"name":"Lance Bragstad","email":"lbragstad@redhat.com","username":"ldbragst"},"change_message_id":"f7a16793b31e168f0b0334d0774dd0f52cc800dd","unresolved":false,"context_lines":[{"line_number":67,"context_line":""},{"line_number":68,"context_line":"This will allow us to later add more complicated checks that could take into"},{"line_number":69,"context_line":"account hierarchical multi-tenancy and/or domain scoped tokens."},{"line_number":70,"context_line":"Note: we need to explicit provide the given tenant_id for the requested"},{"line_number":71,"context_line":"resource, we don\u0027t get what tenants the context has access to. As such,"},{"line_number":72,"context_line":"when you add a server tag, we will need to fetch the server\u0027s project_id so"},{"line_number":73,"context_line":"we can correctly check the scope."}],"source_content_type":"text/x-rst","patch_set":6,"id":"fa31d9ce_b5ae0796","line":70,"updated":"2017-02-14 02:55:29.000000000","message":"explicitly*","commit_id":"f7b400bb87f0313cd2b6c382f0f3be6d27779be6"},{"author":{"_account_id":5046,"name":"Lance Bragstad","email":"lbragstad@redhat.com","username":"ldbragst"},"change_message_id":"f7a16793b31e168f0b0334d0774dd0f52cc800dd","unresolved":false,"context_lines":[{"line_number":73,"context_line":"we can correctly check the scope."},{"line_number":74,"context_line":""},{"line_number":75,"context_line":"To show a keypair, we will pass ``scope\u003d{\"user_id\": \"some-user-id\"}``,"},{"line_number":76,"context_line":"for a show server we would pass ``scope\u003d{\"project_id\": \"some-project-id\"}``,"},{"line_number":77,"context_line":"for a list all servers we would pass ``scope\u003d{}``, i.e. the empty scope"},{"line_number":78,"context_line":"is considered to check for a global scope. If there is no need to check for"},{"line_number":79,"context_line":"a specific scope, there is no need to call the has_access method."}],"source_content_type":"text/x-rst","patch_set":6,"id":"fa31d9ce_f5c95f5a","line":76,"updated":"2017-02-14 02:55:29.000000000","message":"So - I assume the trend is that this would eventually lead to: \n\n  scope\u003d{\"domain_id\": \"default\"}\n\nSo we could start enforcing operations at the domain level?","commit_id":"f7b400bb87f0313cd2b6c382f0f3be6d27779be6"},{"author":{"_account_id":782,"name":"John Garbutt","email":"john@johngarbutt.com","username":"johngarbutt"},"change_message_id":"4663f881f14819fa12ff81d9a8cf2ec8b926e4bf","unresolved":false,"context_lines":[{"line_number":73,"context_line":"we can correctly check the scope."},{"line_number":74,"context_line":""},{"line_number":75,"context_line":"To show a keypair, we will pass ``scope\u003d{\"user_id\": \"some-user-id\"}``,"},{"line_number":76,"context_line":"for a show server we would pass ``scope\u003d{\"project_id\": \"some-project-id\"}``,"},{"line_number":77,"context_line":"for a list all servers we would pass ``scope\u003d{}``, i.e. the empty scope"},{"line_number":78,"context_line":"is considered to check for a global scope. If there is no need to check for"},{"line_number":79,"context_line":"a specific scope, there is no need to call the has_access method."}],"source_content_type":"text/x-rst","patch_set":6,"id":"fa31d9ce_6fee70b5","line":76,"in_reply_to":"fa31d9ce_f5c95f5a","updated":"2017-02-14 09:46:38.000000000","message":"totally, I want to draft that one out.\n\nWell, most will be:\n\n    scope \u003d {\n      \"domain_id\": server.domain_id,\n      \"project_id\": server.project_id}","commit_id":"f7b400bb87f0313cd2b6c382f0f3be6d27779be6"},{"author":{"_account_id":5046,"name":"Lance Bragstad","email":"lbragstad@redhat.com","username":"ldbragst"},"change_message_id":"f7a16793b31e168f0b0334d0774dd0f52cc800dd","unresolved":false,"context_lines":[{"line_number":76,"context_line":"for a show server we would pass ``scope\u003d{\"project_id\": \"some-project-id\"}``,"},{"line_number":77,"context_line":"for a list all servers we would pass ``scope\u003d{}``, i.e. the empty scope"},{"line_number":78,"context_line":"is considered to check for a global scope. If there is no need to check for"},{"line_number":79,"context_line":"a specific scope, there is no need to call the has_access method."},{"line_number":80,"context_line":""},{"line_number":81,"context_line":"Lets look at a few more examples:"},{"line_number":82,"context_line":""}],"source_content_type":"text/x-rst","patch_set":6,"id":"fa31d9ce_95fca373","line":79,"updated":"2017-02-14 02:55:29.000000000","message":"The `has_access()` method or the `check_scope()` method?","commit_id":"f7b400bb87f0313cd2b6c382f0f3be6d27779be6"},{"author":{"_account_id":782,"name":"John Garbutt","email":"john@johngarbutt.com","username":"johngarbutt"},"change_message_id":"4663f881f14819fa12ff81d9a8cf2ec8b926e4bf","unresolved":false,"context_lines":[{"line_number":76,"context_line":"for a show server we would pass ``scope\u003d{\"project_id\": \"some-project-id\"}``,"},{"line_number":77,"context_line":"for a list all servers we would pass ``scope\u003d{}``, i.e. the empty scope"},{"line_number":78,"context_line":"is considered to check for a global scope. If there is no need to check for"},{"line_number":79,"context_line":"a specific scope, there is no need to call the has_access method."},{"line_number":80,"context_line":""},{"line_number":81,"context_line":"Lets look at a few more examples:"},{"line_number":82,"context_line":""}],"source_content_type":"text/x-rst","patch_set":6,"id":"fa31d9ce_efea60ab","line":79,"in_reply_to":"fa31d9ce_95fca373","updated":"2017-02-14 09:46:38.000000000","message":"I kept changing my mind on what to call that thing, oops.","commit_id":"f7b400bb87f0313cd2b6c382f0f3be6d27779be6"},{"author":{"_account_id":5046,"name":"Lance Bragstad","email":"lbragstad@redhat.com","username":"ldbragst"},"change_message_id":"f7a16793b31e168f0b0334d0774dd0f52cc800dd","unresolved":false,"context_lines":[{"line_number":83,"context_line":"* PUT /servers/id"},{"line_number":84,"context_line":""},{"line_number":85,"context_line":"  * scope check: {\"project_id\": \"server.project_id\" }"},{"line_number":86,"context_line":"  * admin_or_owner"},{"line_number":87,"context_line":""},{"line_number":88,"context_line":"* GET /servers?all_tenants\u003dTrue"},{"line_number":89,"context_line":""}],"source_content_type":"text/x-rst","patch_set":6,"id":"fa31d9ce_3545b7b2","line":86,"updated":"2017-02-14 02:55:29.000000000","message":"I thought we wanted to get rid of the `admin_or_owner` mentality? Does this imply global admin, owner of the server, member of the project, etc?","commit_id":"f7b400bb87f0313cd2b6c382f0f3be6d27779be6"},{"author":{"_account_id":782,"name":"John Garbutt","email":"john@johngarbutt.com","username":"johngarbutt"},"change_message_id":"4663f881f14819fa12ff81d9a8cf2ec8b926e4bf","unresolved":false,"context_lines":[{"line_number":83,"context_line":"* PUT /servers/id"},{"line_number":84,"context_line":""},{"line_number":85,"context_line":"  * scope check: {\"project_id\": \"server.project_id\" }"},{"line_number":86,"context_line":"  * admin_or_owner"},{"line_number":87,"context_line":""},{"line_number":88,"context_line":"* GET /servers?all_tenants\u003dTrue"},{"line_number":89,"context_line":""}],"source_content_type":"text/x-rst","patch_set":6,"id":"fa31d9ce_6fc0302b","line":86,"in_reply_to":"fa31d9ce_3545b7b2","updated":"2017-02-14 09:46:38.000000000","message":"So, I am actually only keeping this for backwards compatibility reasons, I describe that more below. I should make that clearer up here really.\n\nadmin_or_owner \u003d \"@\" after this change.\n\nThe follow on change actually transforms this a little bit further, so it makes more sense to keep this about for the transition.","commit_id":"f7b400bb87f0313cd2b6c382f0f3be6d27779be6"},{"author":{"_account_id":5754,"name":"Alex Xu","email":"hejie.xu@intel.com","username":"xuhj"},"change_message_id":"001cb9e3b35d46c139d69ae68803f28521cb0dae","unresolved":false,"context_lines":[{"line_number":85,"context_line":"  * scope check: {\"project_id\": \"server.project_id\" }"},{"line_number":86,"context_line":"  * admin_or_owner"},{"line_number":87,"context_line":""},{"line_number":88,"context_line":"* GET /servers?all_tenants\u003dTrue"},{"line_number":89,"context_line":""},{"line_number":90,"context_line":"  * scope check: {}"},{"line_number":91,"context_line":"  * admin_or_owner"}],"source_content_type":"text/x-rst","patch_set":6,"id":"fa31d9ce_bca8abdc","line":88,"range":{"start_line":88,"start_character":2,"end_line":88,"end_character":31},"updated":"2017-02-14 07:55:42.000000000","message":"What about \u0027GET /servers\u0027? It needn\u0027t the scope check?","commit_id":"f7b400bb87f0313cd2b6c382f0f3be6d27779be6"},{"author":{"_account_id":782,"name":"John Garbutt","email":"john@johngarbutt.com","username":"johngarbutt"},"change_message_id":"4663f881f14819fa12ff81d9a8cf2ec8b926e4bf","unresolved":false,"context_lines":[{"line_number":85,"context_line":"  * scope check: {\"project_id\": \"server.project_id\" }"},{"line_number":86,"context_line":"  * admin_or_owner"},{"line_number":87,"context_line":""},{"line_number":88,"context_line":"* GET /servers?all_tenants\u003dTrue"},{"line_number":89,"context_line":""},{"line_number":90,"context_line":"  * scope check: {}"},{"line_number":91,"context_line":"  * admin_or_owner"}],"source_content_type":"text/x-rst","patch_set":6,"id":"fa31d9ce_cf803cfa","line":88,"range":{"start_line":88,"start_character":2,"end_line":88,"end_character":31},"in_reply_to":"fa31d9ce_bca8abdc","updated":"2017-02-14 09:46:38.000000000","message":"Sorry, slightly unclear, but {} means check for global scope, i.e. an unrestricted scope.","commit_id":"f7b400bb87f0313cd2b6c382f0f3be6d27779be6"},{"author":{"_account_id":5046,"name":"Lance Bragstad","email":"lbragstad@redhat.com","username":"ldbragst"},"change_message_id":"f7a16793b31e168f0b0334d0774dd0f52cc800dd","unresolved":false,"context_lines":[{"line_number":110,"context_line":"A key part of this work will be to ensure we have good tests for all the new"},{"line_number":111,"context_line":"checks that are added in the API, including tests that excercise the in code"},{"line_number":112,"context_line":"policy defaults rather than using a test specific policy file. We should"},{"line_number":113,"context_line":"write these as functional tests, so the DB layer is not faked out."},{"line_number":114,"context_line":""},{"line_number":115,"context_line":"Once the above tests are in place, we can remove the existing scope checks"},{"line_number":116,"context_line":"from the DB layer, knowing the checks are now in the API layer, and well"}],"source_content_type":"text/x-rst","patch_set":6,"id":"fa31d9ce_9558238c","line":113,"updated":"2017-02-14 02:55:29.000000000","message":"I completely agree. Not to trudge through the implementation details, but have you thought about how you\u0027d want these to look?","commit_id":"f7b400bb87f0313cd2b6c382f0f3be6d27779be6"},{"author":{"_account_id":782,"name":"John Garbutt","email":"john@johngarbutt.com","username":"johngarbutt"},"change_message_id":"4663f881f14819fa12ff81d9a8cf2ec8b926e4bf","unresolved":false,"context_lines":[{"line_number":110,"context_line":"A key part of this work will be to ensure we have good tests for all the new"},{"line_number":111,"context_line":"checks that are added in the API, including tests that excercise the in code"},{"line_number":112,"context_line":"policy defaults rather than using a test specific policy file. We should"},{"line_number":113,"context_line":"write these as functional tests, so the DB layer is not faked out."},{"line_number":114,"context_line":""},{"line_number":115,"context_line":"Once the above tests are in place, we can remove the existing scope checks"},{"line_number":116,"context_line":"from the DB layer, knowing the checks are now in the API layer, and well"}],"source_content_type":"text/x-rst","patch_set":6,"id":"fa31d9ce_afcea82b","line":113,"in_reply_to":"fa31d9ce_9558238c","updated":"2017-02-14 09:46:38.000000000","message":"I have a bit actually.\n\nI am thinking we make it very similar to the DB functional tests we have, but create a context, and a fake request, and call the API controller (with RPC api mocked out, but not the DB).\n\nThere would be a framework where we try the API with a predefined set of contexts, and ensure we get the correct return codes (i.e 403 where needed). Basically we tell it if the API is admin_api or admin_or_owner API.\n\nShould be fairly simple, but test the policy and the DB layer at the same time.","commit_id":"f7b400bb87f0313cd2b6c382f0f3be6d27779be6"},{"author":{"_account_id":5754,"name":"Alex Xu","email":"hejie.xu@intel.com","username":"xuhj"},"change_message_id":"cb5f772d9f96c18c6e3df75d1e0d0c0cfae56ab7","unresolved":false,"context_lines":[{"line_number":125,"context_line":""},{"line_number":126,"context_line":"TODO - check we get warnings from oslo.policy for the unknown rules"},{"line_number":127,"context_line":""},{"line_number":128,"context_line":"Updating policy defaults"},{"line_number":129,"context_line":"------------------------"},{"line_number":130,"context_line":""},{"line_number":131,"context_line":"At this point, we should update the default policy rules to reflect what"}],"source_content_type":"text/x-rst","patch_set":6,"id":"fa31d9ce_48725b12","line":128,"updated":"2017-02-15 02:56:40.000000000","message":"I guess this proposal will stop to support this also http://specs.openstack.org/openstack/nova-specs/specs/newton/implemented/user-id-based-policy-enforcement.html\nIt is worth a note at somewhere.","commit_id":"f7b400bb87f0313cd2b6c382f0f3be6d27779be6"},{"author":{"_account_id":782,"name":"John Garbutt","email":"john@johngarbutt.com","username":"johngarbutt"},"change_message_id":"291d1ef1149bb712c52195e3fe2334967a8fb13b","unresolved":false,"context_lines":[{"line_number":125,"context_line":""},{"line_number":126,"context_line":"TODO - check we get warnings from oslo.policy for the unknown rules"},{"line_number":127,"context_line":""},{"line_number":128,"context_line":"Updating policy defaults"},{"line_number":129,"context_line":"------------------------"},{"line_number":130,"context_line":""},{"line_number":131,"context_line":"At this point, we should update the default policy rules to reflect what"}],"source_content_type":"text/x-rst","patch_set":6,"id":"fa31d9ce_aa61f906","line":128,"in_reply_to":"fa31d9ce_48725b12","updated":"2017-02-15 12:48:18.000000000","message":"No, I thought I added a note at some point to say we would keep that support, by still providing the policy target for those cases. Maybe I lots that in my re-writing of the spec.","commit_id":"f7b400bb87f0313cd2b6c382f0f3be6d27779be6"}],"specs/pike/approved/policy-remove-scope-checks.rst":[{"author":{"_account_id":5754,"name":"Alex Xu","email":"hejie.xu@intel.com","username":"xuhj"},"change_message_id":"21a8c4652a56122504721dafba47d09f7538f94d","unresolved":false,"context_lines":[{"line_number":112,"context_line":"  * rule:admin_or_owner"},{"line_number":113,"context_line":"  * (See the policy changes for why we keep the above rule)"},{"line_number":114,"context_line":""},{"line_number":115,"context_line":"* GET /servers?all_tenants\u003dTrue"},{"line_number":116,"context_line":""},{"line_number":117,"context_line":"  * scope check: {} (Note: this means check we are globally scoped)"},{"line_number":118,"context_line":"  * rule:admin_or_owner"}],"source_content_type":"text/x-rst","patch_set":9,"id":"fa31d9ce_cb43a511","line":115,"updated":"2017-02-15 03:10:25.000000000","message":"I commented in https://review.openstack.org/#/c/427872/7, the \u0027GET /servers\u0027 and \u0027POST /servers\u0027 still confuse me.","commit_id":"8858662e273e1293e6f7e047cfedcc3288c75fd3"},{"author":{"_account_id":782,"name":"John Garbutt","email":"john@johngarbutt.com","username":"johngarbutt"},"change_message_id":"8289be45357bcb973b36999afda36277482ff3f1","unresolved":false,"context_lines":[{"line_number":112,"context_line":"  * rule:admin_or_owner"},{"line_number":113,"context_line":"  * (See the policy changes for why we keep the above rule)"},{"line_number":114,"context_line":""},{"line_number":115,"context_line":"* GET /servers?all_tenants\u003dTrue"},{"line_number":116,"context_line":""},{"line_number":117,"context_line":"  * scope check: {} (Note: this means check we are globally scoped)"},{"line_number":118,"context_line":"  * rule:admin_or_owner"}],"source_content_type":"text/x-rst","patch_set":9,"id":"fa31d9ce_ea2e91a3","line":115,"in_reply_to":"fa31d9ce_cb43a511","updated":"2017-02-15 12:48:05.000000000","message":"Sorry, I missed your comment.\n\nI am trying to write this in the language of the operator, and make us think like the operator here. This is the REST API as described in the api-ref that the operator wants to think about.\n\nI should include the rule name here, I missed that off for some reason.\n\nDoes that make sense?","commit_id":"8858662e273e1293e6f7e047cfedcc3288c75fd3"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"07436fd178db22cfc23bfa5957b5c2df55cd7af7","unresolved":false,"context_lines":[{"line_number":21,"context_line":"Problem description"},{"line_number":22,"context_line":"\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d"},{"line_number":23,"context_line":""},{"line_number":24,"context_line":"The current policy defaults create a lot of confusion for operators. We have"},{"line_number":25,"context_line":"lots of APIs that have the admin_or_owner policy check, but don\u0027t specify a"},{"line_number":26,"context_line":"target for that check. Because the default target passes in values from the"},{"line_number":27,"context_line":"context, the rule always passes."},{"line_number":28,"context_line":""},{"line_number":29,"context_line":"The DB layer currently enforces the project membership requirements of each"},{"line_number":30,"context_line":"API. It uses the ``is_admin`` attribute on the context, itself defined by the"}],"source_content_type":"text/x-rst","patch_set":11,"id":"da36d5c6_cdcd9032","line":27,"range":{"start_line":24,"start_character":0,"end_line":27,"end_character":32},"updated":"2017-02-23 19:06:40.000000000","message":"An example here would be helpful.","commit_id":"da6e7e936663f5ba70da1c06ca0c8ae00191e2d6"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"07436fd178db22cfc23bfa5957b5c2df55cd7af7","unresolved":false,"context_lines":[{"line_number":26,"context_line":"target for that check. Because the default target passes in values from the"},{"line_number":27,"context_line":"context, the rule always passes."},{"line_number":28,"context_line":""},{"line_number":29,"context_line":"The DB layer currently enforces the project membership requirements of each"},{"line_number":30,"context_line":"API. It uses the ``is_admin`` attribute on the context, itself defined by the"},{"line_number":31,"context_line":"``context_is_admin`` policy rule, to decide if the token has a \"global\" scope"},{"line_number":32,"context_line":"or not. Global scope means your roles apply across resources belonging to"},{"line_number":33,"context_line":"all projects and users on the system, rather than just the project_id and"}],"source_content_type":"text/x-rst","patch_set":11,"id":"da36d5c6_e8232256","line":30,"range":{"start_line":29,"start_character":0,"end_line":30,"end_character":4},"updated":"2017-02-23 19:06:40.000000000","message":"Would be useful to provide a link reference to the code you\u0027re talking about here. I think it\u0027s model_query but still.","commit_id":"da6e7e936663f5ba70da1c06ca0c8ae00191e2d6"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"07436fd178db22cfc23bfa5957b5c2df55cd7af7","unresolved":false,"context_lines":[{"line_number":48,"context_line":"scope related checks to be clearly visible in the API code. Having the checks"},{"line_number":49,"context_line":"spread across the code makes it hard to verify we are doing the correct thing."},{"line_number":50,"context_line":"Moreover, the current testing of policy is very inconsistent, and doesn\u0027t"},{"line_number":51,"context_line":"really use the default policy that is in the code. We need to ensure we have"},{"line_number":52,"context_line":"rock solid testing of this security sensitive area."},{"line_number":53,"context_line":""},{"line_number":54,"context_line":"While we could consider how to make Nova domain aware, and how to deal with"},{"line_number":55,"context_line":"a domain scoped token, for now, we will concentrate on tidying up the"}],"source_content_type":"text/x-rst","patch_set":11,"id":"da36d5c6_8df71858","line":52,"range":{"start_line":51,"start_character":51,"end_line":52,"end_character":51},"updated":"2017-02-23 19:06:40.000000000","message":"There is a tempest plugin project that does RBAC testing called patrole, maybe we get test coverage via that somehow.","commit_id":"da6e7e936663f5ba70da1c06ca0c8ae00191e2d6"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"07436fd178db22cfc23bfa5957b5c2df55cd7af7","unresolved":false,"context_lines":[{"line_number":56,"context_line":"existing behaviour. With that sorted, it should be much clearer what is"},{"line_number":57,"context_line":"required to add the concept of domains and domain scoped tokens."},{"line_number":58,"context_line":""},{"line_number":59,"context_line":"We we will know we have got this right, when its very clear to a deployer"},{"line_number":60,"context_line":"what control they actually have from the policy file. (That assumes we have"},{"line_number":61,"context_line":"already completed to work to document every policy rule!)"},{"line_number":62,"context_line":""}],"source_content_type":"text/x-rst","patch_set":11,"id":"da36d5c6_ad64dc21","line":59,"range":{"start_line":59,"start_character":0,"end_line":59,"end_character":5},"updated":"2017-02-23 19:06:40.000000000","message":"We","commit_id":"da6e7e936663f5ba70da1c06ca0c8ae00191e2d6"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"07436fd178db22cfc23bfa5957b5c2df55cd7af7","unresolved":false,"context_lines":[{"line_number":58,"context_line":""},{"line_number":59,"context_line":"We we will know we have got this right, when its very clear to a deployer"},{"line_number":60,"context_line":"what control they actually have from the policy file. (That assumes we have"},{"line_number":61,"context_line":"already completed to work to document every policy rule!)"},{"line_number":62,"context_line":""},{"line_number":63,"context_line":"Use Cases"},{"line_number":64,"context_line":"---------"}],"source_content_type":"text/x-rst","patch_set":11,"id":"da36d5c6_cd6910fb","line":61,"range":{"start_line":61,"start_character":29,"end_line":61,"end_character":37},"updated":"2017-02-23 19:06:40.000000000","message":"link to https://review.openstack.org/#/c/433010/ ?","commit_id":"da6e7e936663f5ba70da1c06ca0c8ae00191e2d6"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"07436fd178db22cfc23bfa5957b5c2df55cd7af7","unresolved":false,"context_lines":[{"line_number":58,"context_line":""},{"line_number":59,"context_line":"We we will know we have got this right, when its very clear to a deployer"},{"line_number":60,"context_line":"what control they actually have from the policy file. (That assumes we have"},{"line_number":61,"context_line":"already completed to work to document every policy rule!)"},{"line_number":62,"context_line":""},{"line_number":63,"context_line":"Use Cases"},{"line_number":64,"context_line":"---------"}],"source_content_type":"text/x-rst","patch_set":11,"id":"da36d5c6_ed6a54ec","line":61,"range":{"start_line":61,"start_character":18,"end_line":61,"end_character":20},"updated":"2017-02-23 19:06:40.000000000","message":"the","commit_id":"da6e7e936663f5ba70da1c06ca0c8ae00191e2d6"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"07436fd178db22cfc23bfa5957b5c2df55cd7af7","unresolved":false,"context_lines":[{"line_number":68,"context_line":"  that meets the needs of their specific deployment."},{"line_number":69,"context_line":""},{"line_number":70,"context_line":"* Some private clouds want each of their users to administrate their own"},{"line_number":71,"context_line":"  project, such as being able live-migrate their own VMs."},{"line_number":72,"context_line":"  Currently the default policy file only has the option of a global"},{"line_number":73,"context_line":"  administrator. This change makes it much easier to separate those concerns,"},{"line_number":74,"context_line":"  and will allow us to enable this in the default policy in a future spec."}],"source_content_type":"text/x-rst","patch_set":11,"id":"da36d5c6_cd503035","line":71,"range":{"start_line":71,"start_character":25,"end_line":71,"end_character":29},"updated":"2017-02-23 19:06:40.000000000","message":"able to","commit_id":"da6e7e936663f5ba70da1c06ca0c8ae00191e2d6"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"07436fd178db22cfc23bfa5957b5c2df55cd7af7","unresolved":false,"context_lines":[{"line_number":76,"context_line":"Proposed change"},{"line_number":77,"context_line":"\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d"},{"line_number":78,"context_line":""},{"line_number":79,"context_line":"There will be a new policy rule added:::"},{"line_number":80,"context_line":""},{"line_number":81,"context_line":"    \"context_is_global_scope\": \"rule:admin_api\""},{"line_number":82,"context_line":""}],"source_content_type":"text/x-rst","patch_set":11,"id":"da36d5c6_8d539838","line":79,"range":{"start_line":79,"start_character":37,"end_line":79,"end_character":40},"updated":"2017-02-23 19:06:40.000000000","message":"just ::","commit_id":"da6e7e936663f5ba70da1c06ca0c8ae00191e2d6"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"07436fd178db22cfc23bfa5957b5c2df55cd7af7","unresolved":false,"context_lines":[{"line_number":80,"context_line":""},{"line_number":81,"context_line":"    \"context_is_global_scope\": \"rule:admin_api\""},{"line_number":82,"context_line":""},{"line_number":83,"context_line":"The above rule will be used in this new nova context method:::"},{"line_number":84,"context_line":""},{"line_number":85,"context_line":"    def check_scope(scope, fatal\u003dTrue)"},{"line_number":86,"context_line":""}],"source_content_type":"text/x-rst","patch_set":11,"id":"da36d5c6_ed3894f0","line":83,"range":{"start_line":83,"start_character":59,"end_line":83,"end_character":62},"updated":"2017-02-23 19:06:40.000000000","message":"::","commit_id":"da6e7e936663f5ba70da1c06ca0c8ae00191e2d6"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"07436fd178db22cfc23bfa5957b5c2df55cd7af7","unresolved":false,"context_lines":[{"line_number":126,"context_line":""},{"line_number":127,"context_line":"  * no scope check"},{"line_number":128,"context_line":"  * rule:admin_or_owner"},{"line_number":129,"context_line":"  * (The above rule makes little sense, but we keep it aid upgrades)"},{"line_number":130,"context_line":""},{"line_number":131,"context_line":"* POST /flavors"},{"line_number":132,"context_line":""}],"source_content_type":"text/x-rst","patch_set":11,"id":"da36d5c6_48398ed6","line":129,"range":{"start_line":129,"start_character":55,"end_line":129,"end_character":58},"updated":"2017-02-23 19:06:40.000000000","message":"to aid","commit_id":"da6e7e936663f5ba70da1c06ca0c8ae00191e2d6"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"07436fd178db22cfc23bfa5957b5c2df55cd7af7","unresolved":false,"context_lines":[{"line_number":131,"context_line":"* POST /flavors"},{"line_number":132,"context_line":""},{"line_number":133,"context_line":"  * scope check: {} (i.e. global, unless is a project specific flavor)"},{"line_number":134,"context_line":"  * admin_api"},{"line_number":135,"context_line":""},{"line_number":136,"context_line":"Functional Tests"},{"line_number":137,"context_line":"----------------"}],"source_content_type":"text/x-rst","patch_set":11,"id":"da36d5c6_e85402ff","line":134,"range":{"start_line":134,"start_character":4,"end_line":134,"end_character":13},"updated":"2017-02-23 19:06:40.000000000","message":"rule:admin_api","commit_id":"da6e7e936663f5ba70da1c06ca0c8ae00191e2d6"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"07436fd178db22cfc23bfa5957b5c2df55cd7af7","unresolved":false,"context_lines":[{"line_number":137,"context_line":"----------------"},{"line_number":138,"context_line":""},{"line_number":139,"context_line":"A key part of this work will be to ensure we have good tests for all the new"},{"line_number":140,"context_line":"checks that are added in the API, including tests that exercise the in code"},{"line_number":141,"context_line":"policy defaults rather than using a test specific policy file. We should"},{"line_number":142,"context_line":"write these as functional tests, so the DB layer is not faked out."},{"line_number":143,"context_line":""}],"source_content_type":"text/x-rst","patch_set":11,"id":"da36d5c6_4840ae34","line":140,"range":{"start_line":140,"start_character":68,"end_line":140,"end_character":75},"updated":"2017-02-23 19:06:40.000000000","message":"in-code","commit_id":"da6e7e936663f5ba70da1c06ca0c8ae00191e2d6"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"07436fd178db22cfc23bfa5957b5c2df55cd7af7","unresolved":false,"context_lines":[{"line_number":161,"context_line":"At this point, we should update the default policy rules to reflect what"},{"line_number":162,"context_line":"the current checks actually mean."},{"line_number":163,"context_line":""},{"line_number":164,"context_line":"Lets take a look at the some policy rules after this change:::"},{"line_number":165,"context_line":""},{"line_number":166,"context_line":"    # These remain the same"},{"line_number":167,"context_line":"    \"context_is_admin\": \"role:admin\""}],"source_content_type":"text/x-rst","patch_set":11,"id":"da36d5c6_08a876da","line":164,"range":{"start_line":164,"start_character":59,"end_line":164,"end_character":62},"updated":"2017-02-23 19:06:40.000000000","message":"::","commit_id":"da6e7e936663f5ba70da1c06ca0c8ae00191e2d6"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"07436fd178db22cfc23bfa5957b5c2df55cd7af7","unresolved":false,"context_lines":[{"line_number":175,"context_line":""},{"line_number":176,"context_line":"    # This is a real check, so it stays as it is for now"},{"line_number":177,"context_line":"    \"os_compute_api:os-quota-class-sets:show\":"},{"line_number":178,"context_line":"        \"is_admin:True or quota_class:%(quota_class)s\""},{"line_number":179,"context_line":""},{"line_number":180,"context_line":"Note that:"},{"line_number":181,"context_line":""}],"source_content_type":"text/x-rst","patch_set":11,"id":"da36d5c6_484a6e27","line":178,"range":{"start_line":178,"start_character":26,"end_line":178,"end_character":53},"updated":"2017-02-23 19:06:40.000000000","message":"What does this mean? This is the target? What does the effective policy mean for this? Admin or owner of this quota_class?","commit_id":"da6e7e936663f5ba70da1c06ca0c8ae00191e2d6"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"07436fd178db22cfc23bfa5957b5c2df55cd7af7","unresolved":false,"context_lines":[{"line_number":228,"context_line":"---------------"},{"line_number":229,"context_line":""},{"line_number":230,"context_line":"A better understanding of what each rule means can only help operators and"},{"line_number":231,"context_line":"developer get the policy configuration correct. There should be no material"},{"line_number":232,"context_line":"change to the existing checks."},{"line_number":233,"context_line":""},{"line_number":234,"context_line":"Notifications impact"}],"source_content_type":"text/x-rst","patch_set":11,"id":"da36d5c6_085b16f7","line":231,"range":{"start_line":231,"start_character":0,"end_line":231,"end_character":9},"updated":"2017-02-23 19:06:40.000000000","message":"developers","commit_id":"da6e7e936663f5ba70da1c06ca0c8ae00191e2d6"},{"author":{"_account_id":19590,"name":"Sarafraj Singh","email":"Sarafraj.Singh@intel.com","username":"sarafrajsingh"},"change_message_id":"9ab45c4c042f66b3ee3028c3e2766c3b114fc042","unresolved":false,"context_lines":[{"line_number":34,"context_line":"It uses the ``is_admin`` attribute on the context, itself defined by the"},{"line_number":35,"context_line":"``context_is_admin`` policy rule, to decide if the token has a \"global\" scope"},{"line_number":36,"context_line":"or not. Global scope means your roles apply across resources belonging to"},{"line_number":37,"context_line":"all projects and users on the system, rather than just the project_id and"},{"line_number":38,"context_line":"user_id in your context."},{"line_number":39,"context_line":""},{"line_number":40,"context_line":"As an operator, when you see the admin_or_owner policy check, you might"}],"source_content_type":"text/x-rst","patch_set":12,"id":"ba2be162_e2ad7132","line":37,"range":{"start_line":37,"start_character":59,"end_line":37,"end_character":69},"updated":"2017-03-01 17:52:26.000000000","message":"nit: wrap in quotes","commit_id":"2c697d19979ad27491d3849ad025109767782b11"},{"author":{"_account_id":19590,"name":"Sarafraj Singh","email":"Sarafraj.Singh@intel.com","username":"sarafrajsingh"},"change_message_id":"9ab45c4c042f66b3ee3028c3e2766c3b114fc042","unresolved":false,"context_lines":[{"line_number":35,"context_line":"``context_is_admin`` policy rule, to decide if the token has a \"global\" scope"},{"line_number":36,"context_line":"or not. Global scope means your roles apply across resources belonging to"},{"line_number":37,"context_line":"all projects and users on the system, rather than just the project_id and"},{"line_number":38,"context_line":"user_id in your context."},{"line_number":39,"context_line":""},{"line_number":40,"context_line":"As an operator, when you see the admin_or_owner policy check, you might"},{"line_number":41,"context_line":"easily assume you can remove the scope check to allow everyone to perform an"}],"source_content_type":"text/x-rst","patch_set":12,"id":"ba2be162_42639d1a","line":38,"range":{"start_line":38,"start_character":0,"end_line":38,"end_character":7},"updated":"2017-03-01 17:52:26.000000000","message":"same","commit_id":"2c697d19979ad27491d3849ad025109767782b11"},{"author":{"_account_id":5754,"name":"Alex Xu","email":"hejie.xu@intel.com","username":"xuhj"},"change_message_id":"c5076d6ef7fc5fc129916603552cba8a154cc7b9","unresolved":false,"context_lines":[{"line_number":87,"context_line":""},{"line_number":88,"context_line":"The above rule will be used in this new nova context method::"},{"line_number":89,"context_line":""},{"line_number":90,"context_line":"    def check_scope(scope, fatal\u003dTrue)"},{"line_number":91,"context_line":""},{"line_number":92,"context_line":"It will return True, only if the target matches the current context, or the"},{"line_number":93,"context_line":"token passes the context_is_global_scope test. It raises an exception that"}],"source_content_type":"text/x-rst","patch_set":12,"id":"9a30ddce_420d4f8f","line":90,"range":{"start_line":90,"start_character":4,"end_line":90,"end_character":38},"updated":"2017-03-08 09:37:46.000000000","message":"Just dump my thinking at here.\n\nFrom the PoC https://review.openstack.org/#/c/435485/1/nova/api/openstack/compute/servers.py@783,\n\nIt puts the scope into each API method, so I\u0027m thinking how to implement the capabilities discovery.\n\nFor the cloud level capabilities, it is good for having separate scope check, all the policy rules can help for answering the cloud level capabilities. So the user can know whether he have permission for specific API from the cloud level capabilities.\n\nFor the resource level capabilities, probably we need to check the scope for resource level capabilities discover API. So if the user can\u0027t pass the scope check, the user will get 404 from \"GET /resources/{uuid}/info\".\n\nI think we are good at here.\n\ndo we need to expose \u0027scope\u0027 into cloud level capabilities discover API? I guess no, i didn\u0027t find out a case why people want to know the API\u0027s scope.","commit_id":"2c697d19979ad27491d3849ad025109767782b11"},{"author":{"_account_id":782,"name":"John Garbutt","email":"john@johngarbutt.com","username":"johngarbutt"},"change_message_id":"0ad2b26fff3aaaaee02c6d930a2311d7c6792df2","unresolved":false,"context_lines":[{"line_number":87,"context_line":""},{"line_number":88,"context_line":"The above rule will be used in this new nova context method::"},{"line_number":89,"context_line":""},{"line_number":90,"context_line":"    def check_scope(scope, fatal\u003dTrue)"},{"line_number":91,"context_line":""},{"line_number":92,"context_line":"It will return True, only if the target matches the current context, or the"},{"line_number":93,"context_line":"token passes the context_is_global_scope test. It raises an exception that"}],"source_content_type":"text/x-rst","patch_set":12,"id":"3a1ff146_d463af3f","line":90,"range":{"start_line":90,"start_character":4,"end_line":90,"end_character":38},"in_reply_to":"9a30ddce_420d4f8f","updated":"2017-03-16 11:25:11.000000000","message":"I don\u0027t see how this affects the discovery, you are always checking the scope of the token first. I could be missing something.\n\nI think you could have a capability of having \"global\" access, but thats orthogonal to the operation you have access to like snapshot and live-migration.","commit_id":"2c697d19979ad27491d3849ad025109767782b11"},{"author":{"_account_id":19590,"name":"Sarafraj Singh","email":"Sarafraj.Singh@intel.com","username":"sarafrajsingh"},"change_message_id":"9ab45c4c042f66b3ee3028c3e2766c3b114fc042","unresolved":false,"context_lines":[{"line_number":90,"context_line":"    def check_scope(scope, fatal\u003dTrue)"},{"line_number":91,"context_line":""},{"line_number":92,"context_line":"It will return True, only if the target matches the current context, or the"},{"line_number":93,"context_line":"token passes the context_is_global_scope test. It raises an exception that"},{"line_number":94,"context_line":"triggers a 403 error if fatal\u003dTrue, else if fatal\u003dFalse it returns False."},{"line_number":95,"context_line":""},{"line_number":96,"context_line":"This will allow us to later add more complicated checks that could take into"}],"source_content_type":"text/x-rst","patch_set":12,"id":"ba2be162_4231dd0a","line":93,"range":{"start_line":93,"start_character":17,"end_line":93,"end_character":40},"updated":"2017-03-01 17:52:26.000000000","message":"nit: in quotes","commit_id":"2c697d19979ad27491d3849ad025109767782b11"},{"author":{"_account_id":5754,"name":"Alex Xu","email":"hejie.xu@intel.com","username":"xuhj"},"change_message_id":"c5076d6ef7fc5fc129916603552cba8a154cc7b9","unresolved":false,"context_lines":[{"line_number":100,"context_line":"when you add a server tag, we will need to fetch the server\u0027s project_id so"},{"line_number":101,"context_line":"we can correctly check the scope."},{"line_number":102,"context_line":""},{"line_number":103,"context_line":"To show a keypair, we will pass ``scope\u003d{\"user_id\": \"some-user-id\"}``,"},{"line_number":104,"context_line":"for a show server we would pass ``scope\u003d{\"project_id\": \"some-project-id\"}``,"},{"line_number":105,"context_line":"for a list all servers we would pass ``scope\u003d{}``, i.e. the empty scope"},{"line_number":106,"context_line":"is considered to check for a global scope. If there is no need to check for"}],"source_content_type":"text/x-rst","patch_set":12,"id":"9a30ddce_7d7d921b","line":103,"range":{"start_line":103,"start_character":34,"end_line":103,"end_character":39},"updated":"2017-03-08 09:37:46.000000000","message":"the \u0027scope\u0027 is pretty like the \u0027target\u0027 which we used in \u0027context.can\u0027. But I understand now, it is not. The thing confuse me is that `scope\u003d{\"user_id\": \"some-user-id\"}` mixed the scope definition and the target.\n\nMaybe we can define the scope separately, like:\n\nscope\u003d{\"project_id\": \"%{project_id}s\"}\n\nThen the scope check will look like this:\n\ncontext.check_scope(scope\u003d{\"project_id\": \"%{project_id}s\"}, target\u003dinstance)\n\nAnd the scope is defined by Nova, it isn\u0027t configurable by the deployer.\n\nSo we can change move the scope into a constant variables, likes:\n\nPROJECT_SCOPE\u003d{\"project_id\": \"%{project_id}s\"}\nUSER_SCOPE\u003d{\"project_id\": %{user_id}s\"}\nGLOBAL_SCOPE\u003d{}\n\nso the scope check looks like as below:\n\nFor servers:\nconext.check_scope(scope\u003dPROJECT_SCOPE, target\u003dinstance)\n\nFor flavor:\ncontext.check_scope(scope\u003dUSER_SCOPE, target\u003dinstance)\n\nFor all_tenants:\ncontext.check_scope(scope\u003dGLOBAL_SCOPE, target\u003dinstance)","commit_id":"2c697d19979ad27491d3849ad025109767782b11"},{"author":{"_account_id":782,"name":"John Garbutt","email":"john@johngarbutt.com","username":"johngarbutt"},"change_message_id":"0ad2b26fff3aaaaee02c6d930a2311d7c6792df2","unresolved":false,"context_lines":[{"line_number":100,"context_line":"when you add a server tag, we will need to fetch the server\u0027s project_id so"},{"line_number":101,"context_line":"we can correctly check the scope."},{"line_number":102,"context_line":""},{"line_number":103,"context_line":"To show a keypair, we will pass ``scope\u003d{\"user_id\": \"some-user-id\"}``,"},{"line_number":104,"context_line":"for a show server we would pass ``scope\u003d{\"project_id\": \"some-project-id\"}``,"},{"line_number":105,"context_line":"for a list all servers we would pass ``scope\u003d{}``, i.e. the empty scope"},{"line_number":106,"context_line":"is considered to check for a global scope. If there is no need to check for"}],"source_content_type":"text/x-rst","patch_set":12,"id":"3a1ff146_74abdb1d","line":103,"range":{"start_line":103,"start_character":34,"end_line":103,"end_character":39},"in_reply_to":"9a30ddce_7d7d921b","updated":"2017-03-16 11:25:11.000000000","message":"So we spoke on IRC about this, really its more about:\n\nFor all_tenants:\ncontext.check_scope(scope\u003dGLOBAL_SCOPE)\n\nFor key_pairs:\ncontext.check_scope(scope\u003dkeypair.get_scope())\n\nFor servers:\ncontext.check_scope(scope\u003dservers.get_scope())\n\nThe object you are manipulating has an implicit concept of how it is scoped.\n\nInterestingly, some flavors are global, some have a project scope, so left that one out here for now. I think the modification all needs to be admin role, but anyways, thats an interesting one.","commit_id":"2c697d19979ad27491d3849ad025109767782b11"},{"author":{"_account_id":19590,"name":"Sarafraj Singh","email":"Sarafraj.Singh@intel.com","username":"sarafrajsingh"},"change_message_id":"9ab45c4c042f66b3ee3028c3e2766c3b114fc042","unresolved":false,"context_lines":[{"line_number":111,"context_line":""},{"line_number":112,"context_line":"Lets look at a few more examples:"},{"line_number":113,"context_line":""},{"line_number":114,"context_line":"* PUT /servers/id"},{"line_number":115,"context_line":""},{"line_number":116,"context_line":"  * scope check: {\"project_id\": \"server.project_id\" }"},{"line_number":117,"context_line":"  * rule:admin_or_owner"},{"line_number":118,"context_line":"  * (See the policy changes for why we keep the above rule)"},{"line_number":119,"context_line":""},{"line_number":120,"context_line":"* GET /servers?all_tenants\u003dTrue"}],"source_content_type":"text/x-rst","patch_set":12,"id":"ba2be162_f6ca9019","line":117,"range":{"start_line":114,"start_character":2,"end_line":117,"end_character":23},"updated":"2017-03-01 17:52:26.000000000","message":"Will DELETe look like following?:\nDELETE /servers/id\n\n  * scope check: {\"project_id\": \"server.project_id\" }\n  * rule:admin_api","commit_id":"2c697d19979ad27491d3849ad025109767782b11"},{"author":{"_account_id":782,"name":"John Garbutt","email":"john@johngarbutt.com","username":"johngarbutt"},"change_message_id":"0ad2b26fff3aaaaee02c6d930a2311d7c6792df2","unresolved":false,"context_lines":[{"line_number":111,"context_line":""},{"line_number":112,"context_line":"Lets look at a few more examples:"},{"line_number":113,"context_line":""},{"line_number":114,"context_line":"* PUT /servers/id"},{"line_number":115,"context_line":""},{"line_number":116,"context_line":"  * scope check: {\"project_id\": \"server.project_id\" }"},{"line_number":117,"context_line":"  * rule:admin_or_owner"},{"line_number":118,"context_line":"  * (See the policy changes for why we keep the above rule)"},{"line_number":119,"context_line":""},{"line_number":120,"context_line":"* GET /servers?all_tenants\u003dTrue"}],"source_content_type":"text/x-rst","patch_set":12,"id":"3a1ff146_b4639319","line":117,"range":{"start_line":114,"start_character":2,"end_line":117,"end_character":23},"in_reply_to":"ba2be162_f6ca9019","updated":"2017-03-16 11:25:11.000000000","message":"No, because delete is not an admin operation, users can delete.","commit_id":"2c697d19979ad27491d3849ad025109767782b11"},{"author":{"_account_id":19590,"name":"Sarafraj Singh","email":"Sarafraj.Singh@intel.com","username":"sarafrajsingh"},"change_message_id":"9ab45c4c042f66b3ee3028c3e2766c3b114fc042","unresolved":false,"context_lines":[{"line_number":150,"context_line":"from the DB layer, knowing the checks are now in the API layer, and well"},{"line_number":151,"context_line":"tested by the above functional tests."},{"line_number":152,"context_line":""},{"line_number":153,"context_line":"Remove \"discoverable\" rules"},{"line_number":154,"context_line":"---------------------------"},{"line_number":155,"context_line":""},{"line_number":156,"context_line":"There were some policy rules for hiding certain extensions from the"}],"source_content_type":"text/x-rst","patch_set":12,"id":"ba2be162_96e6b4b2","line":153,"range":{"start_line":153,"start_character":0,"end_line":153,"end_character":27},"updated":"2017-03-01 17:52:26.000000000","message":"Example in this section will be nice.","commit_id":"2c697d19979ad27491d3849ad025109767782b11"},{"author":{"_account_id":782,"name":"John Garbutt","email":"john@johngarbutt.com","username":"johngarbutt"},"change_message_id":"0ad2b26fff3aaaaee02c6d930a2311d7c6792df2","unresolved":false,"context_lines":[{"line_number":150,"context_line":"from the DB layer, knowing the checks are now in the API layer, and well"},{"line_number":151,"context_line":"tested by the above functional tests."},{"line_number":152,"context_line":""},{"line_number":153,"context_line":"Remove \"discoverable\" rules"},{"line_number":154,"context_line":"---------------------------"},{"line_number":155,"context_line":""},{"line_number":156,"context_line":"There were some policy rules for hiding certain extensions from the"}],"source_content_type":"text/x-rst","patch_set":12,"id":"3a1ff146_7482fb95","line":153,"range":{"start_line":153,"start_character":0,"end_line":153,"end_character":27},"in_reply_to":"ba2be162_96e6b4b2","updated":"2017-03-16 11:25:11.000000000","message":"yeah, will add those, good idea.","commit_id":"2c697d19979ad27491d3849ad025109767782b11"},{"author":{"_account_id":20217,"name":"Anusha Unnam","email":"anusha.unnam25@gmail.com","username":"aunnam"},"change_message_id":"39fea9aec0a2ae1bc528f5d087c2f2f8c80ffc82","unresolved":false,"context_lines":[{"line_number":11,"context_line":"https://blueprints.launchpad.net/nova/+spec/policy-remove-scope-checks"},{"line_number":12,"context_line":""},{"line_number":13,"context_line":"Here we separate the concerns of what resources a user has access to and"},{"line_number":14,"context_line":"what that user is allowed to do with those resources."},{"line_number":15,"context_line":""},{"line_number":16,"context_line":"What the user is allowed to do to a resources, is based on the roles assigned"},{"line_number":17,"context_line":"to the user, and checked using rules that can be overridden in the policy file."}],"source_content_type":"text/x-rst","patch_set":15,"id":"1a1ced50_5f56252a","line":14,"range":{"start_line":14,"start_character":0,"end_line":14,"end_character":14},"updated":"2017-03-17 22:37:43.000000000","message":"s/what that user/what actions that user?","commit_id":"66a00cf16ce856bd1bda7c54e33afa4055bf7046"},{"author":{"_account_id":18337,"name":"Sujitha","email":"sujitha.neti@intel.com","username":"Sujitha"},"change_message_id":"c016d19140493986ba0b3006c1bdbe973ce0d89e","unresolved":false,"context_lines":[{"line_number":11,"context_line":"https://blueprints.launchpad.net/nova/+spec/policy-remove-scope-checks"},{"line_number":12,"context_line":""},{"line_number":13,"context_line":"Here we separate the concerns of what resources a user has access to and"},{"line_number":14,"context_line":"what that user is allowed to do with those resources."},{"line_number":15,"context_line":""},{"line_number":16,"context_line":"What the user is allowed to do to a resources, is based on the roles assigned"},{"line_number":17,"context_line":"to the user, and checked using rules that can be overridden in the policy file."}],"source_content_type":"text/x-rst","patch_set":15,"id":"1a1ced50_fa03640d","line":14,"range":{"start_line":14,"start_character":32,"end_line":14,"end_character":53},"updated":"2017-03-17 18:16:31.000000000","message":"so policy only checks for what actions the user is allowed to do. But not on which resources. I think we can say:\n\"we separate the concerns of what actions the user is allowed to do and what resources user has access to\" ?","commit_id":"66a00cf16ce856bd1bda7c54e33afa4055bf7046"},{"author":{"_account_id":18337,"name":"Sujitha","email":"sujitha.neti@intel.com","username":"Sujitha"},"change_message_id":"c016d19140493986ba0b3006c1bdbe973ce0d89e","unresolved":false,"context_lines":[{"line_number":17,"context_line":"to the user, and checked using rules that can be overridden in the policy file."},{"line_number":18,"context_line":"None of this will change."},{"line_number":19,"context_line":""},{"line_number":20,"context_line":"What resources a user are allowed to access used to also be defined in the"},{"line_number":21,"context_line":"policy file, although certain restrictions where hard coded in the DB layer."},{"line_number":22,"context_line":"After this change, an explicit scope check is added into all API methods,"},{"line_number":23,"context_line":"next to the policy check. A token is considered global if"}],"source_content_type":"text/x-rst","patch_set":15,"id":"1a1ced50_86f8637e","line":20,"range":{"start_line":20,"start_character":22,"end_line":20,"end_character":25},"updated":"2017-03-17 18:16:31.000000000","message":"s/are/is","commit_id":"66a00cf16ce856bd1bda7c54e33afa4055bf7046"},{"author":{"_account_id":18337,"name":"Sujitha","email":"sujitha.neti@intel.com","username":"Sujitha"},"change_message_id":"c016d19140493986ba0b3006c1bdbe973ce0d89e","unresolved":false,"context_lines":[{"line_number":18,"context_line":"None of this will change."},{"line_number":19,"context_line":""},{"line_number":20,"context_line":"What resources a user are allowed to access used to also be defined in the"},{"line_number":21,"context_line":"policy file, although certain restrictions where hard coded in the DB layer."},{"line_number":22,"context_line":"After this change, an explicit scope check is added into all API methods,"},{"line_number":23,"context_line":"next to the policy check. A token is considered global if"},{"line_number":24,"context_line":"`is_admin_project:True`. If a token is not considered global, that token only"}],"source_content_type":"text/x-rst","patch_set":15,"id":"1a1ced50_663a8738","line":21,"range":{"start_line":21,"start_character":43,"end_line":21,"end_character":48},"updated":"2017-03-17 18:16:31.000000000","message":"s/where/were","commit_id":"66a00cf16ce856bd1bda7c54e33afa4055bf7046"},{"author":{"_account_id":20217,"name":"Anusha Unnam","email":"anusha.unnam25@gmail.com","username":"aunnam"},"change_message_id":"39fea9aec0a2ae1bc528f5d087c2f2f8c80ffc82","unresolved":false,"context_lines":[{"line_number":22,"context_line":"After this change, an explicit scope check is added into all API methods,"},{"line_number":23,"context_line":"next to the policy check. A token is considered global if"},{"line_number":24,"context_line":"`is_admin_project:True`. If a token is not considered global, that token only"},{"line_number":25,"context_line":"has access to resources that match the project_id (and in some cases the"},{"line_number":26,"context_line":"user_id) specified in the token."},{"line_number":27,"context_line":""},{"line_number":28,"context_line":"Note: for backwards compatibility, we will still support restricting a small"},{"line_number":29,"context_line":"list of instance actions based on the user_id. That functionally can only be"}],"source_content_type":"text/x-rst","patch_set":15,"id":"1a1ced50_4259ee59","line":26,"range":{"start_line":25,"start_character":58,"end_line":26,"end_character":7},"updated":"2017-03-17 22:37:43.000000000","message":"such as keypairs?","commit_id":"66a00cf16ce856bd1bda7c54e33afa4055bf7046"},{"author":{"_account_id":782,"name":"John Garbutt","email":"john@johngarbutt.com","username":"johngarbutt"},"change_message_id":"dcd09e8acaa7004abb68e25e478e6f7cddf0e898","unresolved":false,"context_lines":[{"line_number":22,"context_line":"After this change, an explicit scope check is added into all API methods,"},{"line_number":23,"context_line":"next to the policy check. A token is considered global if"},{"line_number":24,"context_line":"`is_admin_project:True`. If a token is not considered global, that token only"},{"line_number":25,"context_line":"has access to resources that match the project_id (and in some cases the"},{"line_number":26,"context_line":"user_id) specified in the token."},{"line_number":27,"context_line":""},{"line_number":28,"context_line":"Note: for backwards compatibility, we will still support restricting a small"},{"line_number":29,"context_line":"list of instance actions based on the user_id. That functionally can only be"}],"source_content_type":"text/x-rst","patch_set":15,"id":"1a1ced50_ec9c6d5f","line":26,"range":{"start_line":25,"start_character":58,"end_line":26,"end_character":7},"in_reply_to":"1a1ced50_4259ee59","updated":"2017-03-20 10:23:46.000000000","message":"yes","commit_id":"66a00cf16ce856bd1bda7c54e33afa4055bf7046"},{"author":{"_account_id":18337,"name":"Sujitha","email":"sujitha.neti@intel.com","username":"Sujitha"},"change_message_id":"c016d19140493986ba0b3006c1bdbe973ce0d89e","unresolved":false,"context_lines":[{"line_number":43,"context_line":"https://git.openstack.org/cgit/openstack/nova/tree/nova/db/sqlalchemy/api.py?id\u003d1585ca189eb6e194441f9dff94c7a710d96e1acc#n321"},{"line_number":44,"context_line":""},{"line_number":45,"context_line":"It uses the ``is_admin`` attribute on the context, itself defined by the"},{"line_number":46,"context_line":"``context_is_admin`` policy rule, to decide if the token has a \"global\" scope"},{"line_number":47,"context_line":"or not. Global scope means your roles apply across resources belonging to"},{"line_number":48,"context_line":"all projects and users on the system, rather than just the `project_id` and"},{"line_number":49,"context_line":"`user_id` in your context."}],"source_content_type":"text/x-rst","patch_set":15,"id":"1a1ced50_e99c886b","line":46,"updated":"2017-03-17 18:16:31.000000000","message":"context_is_admin checks only if the role is admin.  This means global admin in the current code.  Trying to understand how role: admin is different from is_admin:True in the current code.","commit_id":"66a00cf16ce856bd1bda7c54e33afa4055bf7046"},{"author":{"_account_id":782,"name":"John Garbutt","email":"john@johngarbutt.com","username":"johngarbutt"},"change_message_id":"1e493856875cb17a7aae478bec483bf6cb977320","unresolved":false,"context_lines":[{"line_number":43,"context_line":"https://git.openstack.org/cgit/openstack/nova/tree/nova/db/sqlalchemy/api.py?id\u003d1585ca189eb6e194441f9dff94c7a710d96e1acc#n321"},{"line_number":44,"context_line":""},{"line_number":45,"context_line":"It uses the ``is_admin`` attribute on the context, itself defined by the"},{"line_number":46,"context_line":"``context_is_admin`` policy rule, to decide if the token has a \"global\" scope"},{"line_number":47,"context_line":"or not. Global scope means your roles apply across resources belonging to"},{"line_number":48,"context_line":"all projects and users on the system, rather than just the `project_id` and"},{"line_number":49,"context_line":"`user_id` in your context."}],"source_content_type":"text/x-rst","patch_set":15,"id":"1a1ced50_6cf87d4a","line":46,"in_reply_to":"1a1ced50_0ccb8954","updated":"2017-03-20 10:28:44.000000000","message":"Oh I miss read this first time, the context_is_admin policy checks for role:admin, which is used to populate context.is_admin.","commit_id":"66a00cf16ce856bd1bda7c54e33afa4055bf7046"},{"author":{"_account_id":782,"name":"John Garbutt","email":"john@johngarbutt.com","username":"johngarbutt"},"change_message_id":"dcd09e8acaa7004abb68e25e478e6f7cddf0e898","unresolved":false,"context_lines":[{"line_number":43,"context_line":"https://git.openstack.org/cgit/openstack/nova/tree/nova/db/sqlalchemy/api.py?id\u003d1585ca189eb6e194441f9dff94c7a710d96e1acc#n321"},{"line_number":44,"context_line":""},{"line_number":45,"context_line":"It uses the ``is_admin`` attribute on the context, itself defined by the"},{"line_number":46,"context_line":"``context_is_admin`` policy rule, to decide if the token has a \"global\" scope"},{"line_number":47,"context_line":"or not. Global scope means your roles apply across resources belonging to"},{"line_number":48,"context_line":"all projects and users on the system, rather than just the `project_id` and"},{"line_number":49,"context_line":"`user_id` in your context."}],"source_content_type":"text/x-rst","patch_set":15,"id":"1a1ced50_0ccb8954","line":46,"in_reply_to":"1a1ced50_e99c886b","updated":"2017-03-20 10:23:46.000000000","message":"You can be an admin in a project, but not a global admin.\n\nCurrently we only have global admin or regular user.","commit_id":"66a00cf16ce856bd1bda7c54e33afa4055bf7046"},{"author":{"_account_id":20217,"name":"Anusha Unnam","email":"anusha.unnam25@gmail.com","username":"aunnam"},"change_message_id":"39fea9aec0a2ae1bc528f5d087c2f2f8c80ffc82","unresolved":false,"context_lines":[{"line_number":99,"context_line":"access things where project_id matches `context.project_id` unless"},{"line_number":100,"context_line":"`context.is_admin\u003dTrue`."},{"line_number":101,"context_line":""},{"line_number":102,"context_line":"So the Nova RBAC system is easier to understand and use we will:"},{"line_number":103,"context_line":""},{"line_number":104,"context_line":"* add functional tests that should pass before and after the next change"},{"line_number":105,"context_line":"* add explicit \"scope\" checks in the API layer and bypass the DB check"}],"source_content_type":"text/x-rst","patch_set":15,"id":"1a1ced50_0dc80755","line":102,"range":{"start_line":102,"start_character":0,"end_line":102,"end_character":55},"updated":"2017-03-17 22:37:43.000000000","message":"This sentence is confusing.\nso to make Nova RBAC system easier to understand and use?","commit_id":"66a00cf16ce856bd1bda7c54e33afa4055bf7046"},{"author":{"_account_id":20217,"name":"Anusha Unnam","email":"anusha.unnam25@gmail.com","username":"aunnam"},"change_message_id":"39fea9aec0a2ae1bc528f5d087c2f2f8c80ffc82","unresolved":false,"context_lines":[{"line_number":101,"context_line":""},{"line_number":102,"context_line":"So the Nova RBAC system is easier to understand and use we will:"},{"line_number":103,"context_line":""},{"line_number":104,"context_line":"* add functional tests that should pass before and after the next change"},{"line_number":105,"context_line":"* add explicit \"scope\" checks in the API layer and bypass the DB check"},{"line_number":106,"context_line":"* update the policy defaults to reflect there is no scope check"},{"line_number":107,"context_line":"* deprecate the use of the \"target\" in policy checks, but keep the user_id"}],"source_content_type":"text/x-rst","patch_set":15,"id":"1a1ced50_0d24870b","line":104,"range":{"start_line":104,"start_character":61,"end_line":104,"end_character":72},"updated":"2017-03-17 22:37:43.000000000","message":"By \"next change\" you mean removing the scope check from the policy file and adding it in the api?","commit_id":"66a00cf16ce856bd1bda7c54e33afa4055bf7046"},{"author":{"_account_id":782,"name":"John Garbutt","email":"john@johngarbutt.com","username":"johngarbutt"},"change_message_id":"dcd09e8acaa7004abb68e25e478e6f7cddf0e898","unresolved":false,"context_lines":[{"line_number":101,"context_line":""},{"line_number":102,"context_line":"So the Nova RBAC system is easier to understand and use we will:"},{"line_number":103,"context_line":""},{"line_number":104,"context_line":"* add functional tests that should pass before and after the next change"},{"line_number":105,"context_line":"* add explicit \"scope\" checks in the API layer and bypass the DB check"},{"line_number":106,"context_line":"* update the policy defaults to reflect there is no scope check"},{"line_number":107,"context_line":"* deprecate the use of the \"target\" in policy checks, but keep the user_id"}],"source_content_type":"text/x-rst","patch_set":15,"id":"1a1ced50_ccfed16a","line":104,"range":{"start_line":104,"start_character":61,"end_line":104,"end_character":72},"in_reply_to":"1a1ced50_0d24870b","updated":"2017-03-20 10:23:46.000000000","message":"yes.","commit_id":"66a00cf16ce856bd1bda7c54e33afa4055bf7046"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"48d7d76d0ae4cacc76c7e05acca59207204ccff0","unresolved":false,"context_lines":[{"line_number":13,"context_line":"Here we separate the concerns of what resources user has access to and"},{"line_number":14,"context_line":"what actions the user is allowed to do."},{"line_number":15,"context_line":""},{"line_number":16,"context_line":"What the user is allowed to do to a resources, is based on the roles assigned"},{"line_number":17,"context_line":"to the user, and checked using rules that can be overridden in the policy file."},{"line_number":18,"context_line":"None of this will change."},{"line_number":19,"context_line":""}],"source_content_type":"text/x-rst","patch_set":16,"id":"1a1ced50_acb670f6","line":16,"range":{"start_line":16,"start_character":36,"end_line":16,"end_character":45},"updated":"2017-03-22 21:47:39.000000000","message":"resource","commit_id":"8b2e3c75e8543751e36b3c21685ec4e736ea2057"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"48d7d76d0ae4cacc76c7e05acca59207204ccff0","unresolved":false,"context_lines":[{"line_number":17,"context_line":"to the user, and checked using rules that can be overridden in the policy file."},{"line_number":18,"context_line":"None of this will change."},{"line_number":19,"context_line":""},{"line_number":20,"context_line":"What resources a user is allowed to access used to also be defined in the"},{"line_number":21,"context_line":"policy file, although certain restrictions were hard coded in the DB layer."},{"line_number":22,"context_line":"After this change, an explicit scope check is added into all API methods,"},{"line_number":23,"context_line":"next to the policy check. A token is considered global if"}],"source_content_type":"text/x-rst","patch_set":16,"id":"1a1ced50_8c81b4fd","line":20,"range":{"start_line":20,"start_character":43,"end_line":20,"end_character":50},"updated":"2017-03-22 21:47:39.000000000","message":"\"used to\"? As in no longer does? But the paragraph above says that\u0027s in the policy file and doesn\u0027t change, so I\u0027m confused. Examples here would be really helpful for me. Maybe those details happen in the problem description section below.","commit_id":"8b2e3c75e8543751e36b3c21685ec4e736ea2057"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"48d7d76d0ae4cacc76c7e05acca59207204ccff0","unresolved":false,"context_lines":[{"line_number":18,"context_line":"None of this will change."},{"line_number":19,"context_line":""},{"line_number":20,"context_line":"What resources a user is allowed to access used to also be defined in the"},{"line_number":21,"context_line":"policy file, although certain restrictions were hard coded in the DB layer."},{"line_number":22,"context_line":"After this change, an explicit scope check is added into all API methods,"},{"line_number":23,"context_line":"next to the policy check. A token is considered global if"},{"line_number":24,"context_line":"`is_admin_project:True`. If a token is not considered global, that token only"}],"source_content_type":"text/x-rst","patch_set":16,"id":"1a1ced50_8c98d46b","line":21,"range":{"start_line":21,"start_character":13,"end_line":21,"end_character":75},"updated":"2017-03-22 21:47:39.000000000","message":"Were or are? And again, linking directly to the code if it\u0027s still exists and/or giving an example would be helpful for me to understand the problem. Maybe those details happen in the problem description section below.","commit_id":"8b2e3c75e8543751e36b3c21685ec4e736ea2057"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"48d7d76d0ae4cacc76c7e05acca59207204ccff0","unresolved":false,"context_lines":[{"line_number":20,"context_line":"What resources a user is allowed to access used to also be defined in the"},{"line_number":21,"context_line":"policy file, although certain restrictions were hard coded in the DB layer."},{"line_number":22,"context_line":"After this change, an explicit scope check is added into all API methods,"},{"line_number":23,"context_line":"next to the policy check. A token is considered global if"},{"line_number":24,"context_line":"`is_admin_project:True`. If a token is not considered global, that token only"},{"line_number":25,"context_line":"has access to resources that match the project_id (or user_id for things like"},{"line_number":26,"context_line":"Key Pairs) specified in the token."}],"source_content_type":"text/x-rst","patch_set":16,"id":"1a1ced50_2ca8c076","line":23,"range":{"start_line":23,"start_character":26,"end_line":23,"end_character":54},"updated":"2017-03-22 21:47:39.000000000","message":"Global by nova, or global by keystone?","commit_id":"8b2e3c75e8543751e36b3c21685ec4e736ea2057"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"48d7d76d0ae4cacc76c7e05acca59207204ccff0","unresolved":false,"context_lines":[{"line_number":25,"context_line":"has access to resources that match the project_id (or user_id for things like"},{"line_number":26,"context_line":"Key Pairs) specified in the token."},{"line_number":27,"context_line":""},{"line_number":28,"context_line":"Note: for backwards compatibility, we will still support restricting a small"},{"line_number":29,"context_line":"list of instance actions based on the user_id. That functionally can only be"},{"line_number":30,"context_line":"removed once hierarchical quotas has been implemented."},{"line_number":31,"context_line":""},{"line_number":32,"context_line":"Problem description"},{"line_number":33,"context_line":"\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d"}],"source_content_type":"text/x-rst","patch_set":16,"id":"1a1ced50_ecf6a88d","line":30,"range":{"start_line":28,"start_character":0,"end_line":30,"end_character":54},"updated":"2017-03-22 21:47:39.000000000","message":"Is that the same list defined in https://specs.openstack.org/openstack/nova-specs/specs/newton/implemented/user-id-based-policy-enforcement.html and if so, we should reference that spec here.","commit_id":"8b2e3c75e8543751e36b3c21685ec4e736ea2057"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"48d7d76d0ae4cacc76c7e05acca59207204ccff0","unresolved":false,"context_lines":[{"line_number":34,"context_line":""},{"line_number":35,"context_line":"The current policy defaults create a lot of confusion for operators. We have"},{"line_number":36,"context_line":"lots of APIs that have the admin_or_owner policy check, but don\u0027t specify a"},{"line_number":37,"context_line":"target for that check. Because the default target passes in values from the"},{"line_number":38,"context_line":"context, the rule always passes. For example see the server group APIs:"},{"line_number":39,"context_line":"https://git.openstack.org/cgit/openstack/nova/tree/nova/api/openstack/compute/server_groups.py?id\u003d1585ca189eb6e194441f9dff94c7a710d96e1acc#n78"},{"line_number":40,"context_line":""},{"line_number":41,"context_line":"The DB layer currently enforces the project membership requirements of each"}],"source_content_type":"text/x-rst","patch_set":16,"id":"1a1ced50_0c81448f","line":38,"range":{"start_line":37,"start_character":23,"end_line":38,"end_character":32},"updated":"2017-03-22 21:47:39.000000000","message":"Can you expand on this? So ideally the target is the security group we\u0027re actually trying to show in the link below? But without looking up the server group by the given ID how do we know if the project_id in the context has access to show the server group?\n\nHow does having an explicit target in the check solve this?","commit_id":"8b2e3c75e8543751e36b3c21685ec4e736ea2057"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"48d7d76d0ae4cacc76c7e05acca59207204ccff0","unresolved":false,"context_lines":[{"line_number":49,"context_line":"system, rather than just the `project_id` and `user_id` in your context."},{"line_number":50,"context_line":""},{"line_number":51,"context_line":"As an operator, when you see the admin_or_owner policy check, you might"},{"line_number":52,"context_line":"easily assume you can remove the scope check to allow everyone to perform an"},{"line_number":53,"context_line":"action. In reality, you can only use the rule to restrict access in addition"},{"line_number":54,"context_line":"to the hard coded DB checks. This change does not allow administrators to"},{"line_number":55,"context_line":"relax these checks, it just makes what is currently possible more explicit."}],"source_content_type":"text/x-rst","patch_set":16,"id":"1a1ced50_cf239e54","line":52,"range":{"start_line":52,"start_character":22,"end_line":52,"end_character":44},"updated":"2017-03-22 21:47:39.000000000","message":"Remove the scope check, as in make it @ and completely open?","commit_id":"8b2e3c75e8543751e36b3c21685ec4e736ea2057"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"48d7d76d0ae4cacc76c7e05acca59207204ccff0","unresolved":false,"context_lines":[{"line_number":50,"context_line":""},{"line_number":51,"context_line":"As an operator, when you see the admin_or_owner policy check, you might"},{"line_number":52,"context_line":"easily assume you can remove the scope check to allow everyone to perform an"},{"line_number":53,"context_line":"action. In reality, you can only use the rule to restrict access in addition"},{"line_number":54,"context_line":"to the hard coded DB checks. This change does not allow administrators to"},{"line_number":55,"context_line":"relax these checks, it just makes what is currently possible more explicit."},{"line_number":56,"context_line":"Indeed allowing operators full control of the scope is likely to lead to"},{"line_number":57,"context_line":"interoperability problems."}],"source_content_type":"text/x-rst","patch_set":16,"id":"1a1ced50_4f2fae3e","line":54,"range":{"start_line":53,"start_character":8,"end_line":54,"end_character":28},"updated":"2017-03-22 21:47:39.000000000","message":"This is because you can\u0027t open it up based on policy *because* of the project_id check in model_query?","commit_id":"8b2e3c75e8543751e36b3c21685ec4e736ea2057"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"48d7d76d0ae4cacc76c7e05acca59207204ccff0","unresolved":false,"context_lines":[{"line_number":62,"context_line":"From a maintainability and audit point of view, ideally we want all policy and"},{"line_number":63,"context_line":"scope related checks to be clearly visible in the API code. Having the checks"},{"line_number":64,"context_line":"spread across the code makes it hard to verify we are doing the correct thing."},{"line_number":65,"context_line":"Moreover, the current testing of policy is very inconsistent, and doesn\u0027t"},{"line_number":66,"context_line":"really use the default policy that is in the code. We need to ensure we have"},{"line_number":67,"context_line":"rock solid testing of this security sensitive area."},{"line_number":68,"context_line":""},{"line_number":69,"context_line":"While we could consider how to make Nova domain aware, and how to deal with"}],"source_content_type":"text/x-rst","patch_set":16,"id":"1a1ced50_cfa63ead","line":66,"range":{"start_line":65,"start_character":0,"end_line":66,"end_character":50},"updated":"2017-03-22 21:47:39.000000000","message":"How so? We use the RealPolicyFixture in functional tests, and devstack isn\u0027t messing with policy at all so Tempest is running with default policy right?","commit_id":"8b2e3c75e8543751e36b3c21685ec4e736ea2057"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"48d7d76d0ae4cacc76c7e05acca59207204ccff0","unresolved":false,"context_lines":[{"line_number":92,"context_line":"Proposed change"},{"line_number":93,"context_line":"\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d"},{"line_number":94,"context_line":""},{"line_number":95,"context_line":"Currently the policy file checks the roles the user has (to see if it is"},{"line_number":96,"context_line":"allowed to perform the given action) and also checks the token has the"},{"line_number":97,"context_line":"correct scope to access the target resource. This logic is undermined by"},{"line_number":98,"context_line":"the additional checks done in the database layer to enforce you can only"}],"source_content_type":"text/x-rst","patch_set":16,"id":"1a1ced50_6f31ca59","line":95,"range":{"start_line":95,"start_character":14,"end_line":95,"end_character":32},"updated":"2017-03-22 21:47:39.000000000","message":"The policy file doesn\u0027t actually \"check\" anything, it just defines the rules. Another system (oslo.policy?) validates if the rule works with the resource and scope on the token, right?","commit_id":"8b2e3c75e8543751e36b3c21685ec4e736ea2057"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"48d7d76d0ae4cacc76c7e05acca59207204ccff0","unresolved":false,"context_lines":[{"line_number":99,"context_line":"access things where project_id matches `context.project_id` unless"},{"line_number":100,"context_line":"`context.is_admin\u003dTrue`."},{"line_number":101,"context_line":""},{"line_number":102,"context_line":"To make the Nova RBAC system easier to understand and use we will:"},{"line_number":103,"context_line":""},{"line_number":104,"context_line":"* add functional tests (ideally they should pass before and after adding"},{"line_number":105,"context_line":"  the explicit scope checks)"}],"source_content_type":"text/x-rst","patch_set":16,"id":"1a1ced50_6fc2aaea","line":102,"updated":"2017-03-22 21:47:39.000000000","message":"You might want to make a note that these are all explained in more detail below...because I didn\u0027t read the whole spec first before commenting on some of these.","commit_id":"8b2e3c75e8543751e36b3c21685ec4e736ea2057"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"48d7d76d0ae4cacc76c7e05acca59207204ccff0","unresolved":false,"context_lines":[{"line_number":103,"context_line":""},{"line_number":104,"context_line":"* add functional tests (ideally they should pass before and after adding"},{"line_number":105,"context_line":"  the explicit scope checks)"},{"line_number":106,"context_line":"* add explicit \"scope\" checks in the API layer and bypass the DB check"},{"line_number":107,"context_line":"* update the policy defaults to reflect there is no scope check"},{"line_number":108,"context_line":"* deprecate the use of the \"target\" in policy checks, but keep the user_id"},{"line_number":109,"context_line":"  restrictions working until we have hierarchical quotas."}],"source_content_type":"text/x-rst","patch_set":16,"id":"1a1ced50_af0e6289","line":106,"range":{"start_line":106,"start_character":2,"end_line":106,"end_character":70},"updated":"2017-03-22 21:47:39.000000000","message":"What would these explicit checks look like?","commit_id":"8b2e3c75e8543751e36b3c21685ec4e736ea2057"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"48d7d76d0ae4cacc76c7e05acca59207204ccff0","unresolved":false,"context_lines":[{"line_number":104,"context_line":"* add functional tests (ideally they should pass before and after adding"},{"line_number":105,"context_line":"  the explicit scope checks)"},{"line_number":106,"context_line":"* add explicit \"scope\" checks in the API layer and bypass the DB check"},{"line_number":107,"context_line":"* update the policy defaults to reflect there is no scope check"},{"line_number":108,"context_line":"* deprecate the use of the \"target\" in policy checks, but keep the user_id"},{"line_number":109,"context_line":"  restrictions working until we have hierarchical quotas."},{"line_number":110,"context_line":"* tidy up: remove \"discoverable\" rules around extension list"}],"source_content_type":"text/x-rst","patch_set":16,"id":"1a1ced50_0f2056f6","line":107,"range":{"start_line":107,"start_character":2,"end_line":107,"end_character":63},"updated":"2017-03-22 21:47:39.000000000","message":"What does this look like? @?","commit_id":"8b2e3c75e8543751e36b3c21685ec4e736ea2057"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"48d7d76d0ae4cacc76c7e05acca59207204ccff0","unresolved":false,"context_lines":[{"line_number":107,"context_line":"* update the policy defaults to reflect there is no scope check"},{"line_number":108,"context_line":"* deprecate the use of the \"target\" in policy checks, but keep the user_id"},{"line_number":109,"context_line":"  restrictions working until we have hierarchical quotas."},{"line_number":110,"context_line":"* tidy up: remove \"discoverable\" rules around extension list"},{"line_number":111,"context_line":""},{"line_number":112,"context_line":"At the end of these changes, the policy file, and its defaults will look"},{"line_number":113,"context_line":"very similar to a project that is not multi-tenant, except for a single"}],"source_content_type":"text/x-rst","patch_set":16,"id":"1a1ced50_8fe7e6aa","line":110,"range":{"start_line":110,"start_character":2,"end_line":110,"end_character":60},"updated":"2017-03-22 21:47:39.000000000","message":"Why? Are they no longer used?","commit_id":"8b2e3c75e8543751e36b3c21685ec4e736ea2057"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"48d7d76d0ae4cacc76c7e05acca59207204ccff0","unresolved":false,"context_lines":[{"line_number":110,"context_line":"* tidy up: remove \"discoverable\" rules around extension list"},{"line_number":111,"context_line":""},{"line_number":112,"context_line":"At the end of these changes, the policy file, and its defaults will look"},{"line_number":113,"context_line":"very similar to a project that is not multi-tenant, except for a single"},{"line_number":114,"context_line":"rule that checks if a token is global scope or not."},{"line_number":115,"context_line":""},{"line_number":116,"context_line":"Functional Tests"}],"source_content_type":"text/x-rst","patch_set":16,"id":"1a1ced50_afeae271","line":113,"range":{"start_line":113,"start_character":18,"end_line":113,"end_character":25},"updated":"2017-03-22 21:47:39.000000000","message":"A project or a deployment?","commit_id":"8b2e3c75e8543751e36b3c21685ec4e736ea2057"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"48d7d76d0ae4cacc76c7e05acca59207204ccff0","unresolved":false,"context_lines":[{"line_number":147,"context_line":""},{"line_number":148,"context_line":"This will allow us to later add more complicated checks that could take into"},{"line_number":149,"context_line":"account hierarchical multi-tenancy and/or domain scoped tokens."},{"line_number":150,"context_line":"Note: we need to explicitly provide the given tenant_id for the requested"},{"line_number":151,"context_line":"resource, we don\u0027t get what tenants the context has access to. As such,"},{"line_number":152,"context_line":"when you add a server tag, we will need to fetch the server\u0027s project_id so"},{"line_number":153,"context_line":"we can correctly check the scope."}],"source_content_type":"text/x-rst","patch_set":16,"id":"1a1ced50_ef5cda4c","line":150,"range":{"start_line":150,"start_character":28,"end_line":150,"end_character":35},"updated":"2017-03-22 21:47:39.000000000","message":"Provide to what? The check_scope method above? That doesn\u0027t take a project_id parameter.","commit_id":"8b2e3c75e8543751e36b3c21685ec4e736ea2057"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"48d7d76d0ae4cacc76c7e05acca59207204ccff0","unresolved":false,"context_lines":[{"line_number":147,"context_line":""},{"line_number":148,"context_line":"This will allow us to later add more complicated checks that could take into"},{"line_number":149,"context_line":"account hierarchical multi-tenancy and/or domain scoped tokens."},{"line_number":150,"context_line":"Note: we need to explicitly provide the given tenant_id for the requested"},{"line_number":151,"context_line":"resource, we don\u0027t get what tenants the context has access to. As such,"},{"line_number":152,"context_line":"when you add a server tag, we will need to fetch the server\u0027s project_id so"},{"line_number":153,"context_line":"we can correctly check the scope."}],"source_content_type":"text/x-rst","patch_set":16,"id":"1a1ced50_cf7abebc","line":150,"range":{"start_line":150,"start_character":46,"end_line":150,"end_character":55},"updated":"2017-03-22 21:47:39.000000000","message":"nit: should probably say project_id here to use consistent terminology.","commit_id":"8b2e3c75e8543751e36b3c21685ec4e736ea2057"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"48d7d76d0ae4cacc76c7e05acca59207204ccff0","unresolved":false,"context_lines":[{"line_number":148,"context_line":"This will allow us to later add more complicated checks that could take into"},{"line_number":149,"context_line":"account hierarchical multi-tenancy and/or domain scoped tokens."},{"line_number":150,"context_line":"Note: we need to explicitly provide the given tenant_id for the requested"},{"line_number":151,"context_line":"resource, we don\u0027t get what tenants the context has access to. As such,"},{"line_number":152,"context_line":"when you add a server tag, we will need to fetch the server\u0027s project_id so"},{"line_number":153,"context_line":"we can correctly check the scope."},{"line_number":154,"context_line":""}],"source_content_type":"text/x-rst","patch_set":16,"id":"1a1ced50_8f3a86e5","line":151,"range":{"start_line":151,"start_character":10,"end_line":151,"end_character":61},"updated":"2017-03-22 21:47:39.000000000","message":"This confuses me. Get from where? Keystone?","commit_id":"8b2e3c75e8543751e36b3c21685ec4e736ea2057"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"48d7d76d0ae4cacc76c7e05acca59207204ccff0","unresolved":false,"context_lines":[{"line_number":152,"context_line":"when you add a server tag, we will need to fetch the server\u0027s project_id so"},{"line_number":153,"context_line":"we can correctly check the scope."},{"line_number":154,"context_line":""},{"line_number":155,"context_line":"To show a keypair, we will pass ``scope\u003d{\"user_id\": keypair.user_id}``,"},{"line_number":156,"context_line":"for a show server we would pass ``scope\u003d{\"project_id\": instance.project_id}``,"},{"line_number":157,"context_line":"for a list of all servers across all project we would pass ``scope\u003d{}``,"},{"line_number":158,"context_line":"i.e. to represent \"global\" scope, we use the empty scope. If you consider"}],"source_content_type":"text/x-rst","patch_set":16,"id":"1a1ced50_af3d82de","line":155,"range":{"start_line":155,"start_character":34,"end_line":155,"end_character":39},"updated":"2017-03-22 21:47:39.000000000","message":"So scope really replaces target in the context.can() method now right?","commit_id":"8b2e3c75e8543751e36b3c21685ec4e736ea2057"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"48d7d76d0ae4cacc76c7e05acca59207204ccff0","unresolved":false,"context_lines":[{"line_number":154,"context_line":""},{"line_number":155,"context_line":"To show a keypair, we will pass ``scope\u003d{\"user_id\": keypair.user_id}``,"},{"line_number":156,"context_line":"for a show server we would pass ``scope\u003d{\"project_id\": instance.project_id}``,"},{"line_number":157,"context_line":"for a list of all servers across all project we would pass ``scope\u003d{}``,"},{"line_number":158,"context_line":"i.e. to represent \"global\" scope, we use the empty scope. If you consider"},{"line_number":159,"context_line":"listing all global flavors in the system, any token scope is allowed to do"},{"line_number":160,"context_line":"that, so no scope check is performed. But if you modify a global flavor,"}],"source_content_type":"text/x-rst","patch_set":16,"id":"1a1ced50_6f1e2a71","line":157,"range":{"start_line":157,"start_character":59,"end_line":157,"end_character":71},"updated":"2017-03-22 21:47:39.000000000","message":"And this is equivalent to not passing the target arg to context.can today?","commit_id":"8b2e3c75e8543751e36b3c21685ec4e736ea2057"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"48d7d76d0ae4cacc76c7e05acca59207204ccff0","unresolved":false,"context_lines":[{"line_number":155,"context_line":"To show a keypair, we will pass ``scope\u003d{\"user_id\": keypair.user_id}``,"},{"line_number":156,"context_line":"for a show server we would pass ``scope\u003d{\"project_id\": instance.project_id}``,"},{"line_number":157,"context_line":"for a list of all servers across all project we would pass ``scope\u003d{}``,"},{"line_number":158,"context_line":"i.e. to represent \"global\" scope, we use the empty scope. If you consider"},{"line_number":159,"context_line":"listing all global flavors in the system, any token scope is allowed to do"},{"line_number":160,"context_line":"that, so no scope check is performed. But if you modify a global flavor,"},{"line_number":161,"context_line":"a global scope check should be performed, because only a token with global"}],"source_content_type":"text/x-rst","patch_set":16,"id":"1a1ced50_4a023c0b","line":158,"range":{"start_line":158,"start_character":0,"end_line":158,"end_character":57},"updated":"2017-03-22 21:47:39.000000000","message":"How do we know if we want global scope or not? Don\u0027t we have to read that from the policy file? Or is this for things that are hard-coded to be admin-only in the code?","commit_id":"8b2e3c75e8543751e36b3c21685ec4e736ea2057"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"48d7d76d0ae4cacc76c7e05acca59207204ccff0","unresolved":false,"context_lines":[{"line_number":157,"context_line":"for a list of all servers across all project we would pass ``scope\u003d{}``,"},{"line_number":158,"context_line":"i.e. to represent \"global\" scope, we use the empty scope. If you consider"},{"line_number":159,"context_line":"listing all global flavors in the system, any token scope is allowed to do"},{"line_number":160,"context_line":"that, so no scope check is performed. But if you modify a global flavor,"},{"line_number":161,"context_line":"a global scope check should be performed, because only a token with global"},{"line_number":162,"context_line":"scope is allowed to modify flavors."},{"line_number":163,"context_line":""},{"line_number":164,"context_line":"Lets look at a few more examples:"},{"line_number":165,"context_line":""}],"source_content_type":"text/x-rst","patch_set":16,"id":"1a1ced50_8a6d14ce","line":162,"range":{"start_line":160,"start_character":38,"end_line":162,"end_character":35},"updated":"2017-03-22 21:47:39.000000000","message":"If I\u0027m understanding correctly, it has to be global scope because that\u0027s basically admin, and create/delete operations on flavors is an admin-only operation:\n\n\"os_compute_api:os-flavor-manage\": \"rule:admin_api\"\n\nBut I thought you could modify the rule on that to be non-admin, so admin or owner could create and manage their own flavors, or just @ for anyone has access to create flavors? So in this regard, I\u0027m unclear on how global scope is different from the admin-only API rule (which can be changed).","commit_id":"8b2e3c75e8543751e36b3c21685ec4e736ea2057"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"48d7d76d0ae4cacc76c7e05acca59207204ccff0","unresolved":false,"context_lines":[{"line_number":176,"context_line":""},{"line_number":177,"context_line":"* GET /servers?all_tenants\u003dTrue"},{"line_number":178,"context_line":""},{"line_number":179,"context_line":"  * scope check: {} (Note: this means check we are globally scoped)"},{"line_number":180,"context_line":"  * rule:admin_or_owner"},{"line_number":181,"context_line":""},{"line_number":182,"context_line":"* POST /servers"}],"source_content_type":"text/x-rst","patch_set":16,"id":"1a1ced50_8a7b547a","line":179,"range":{"start_line":179,"start_character":32,"end_line":179,"end_character":43},"updated":"2017-03-22 21:47:39.000000000","message":"check means?","commit_id":"8b2e3c75e8543751e36b3c21685ec4e736ea2057"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"48d7d76d0ae4cacc76c7e05acca59207204ccff0","unresolved":false,"context_lines":[{"line_number":177,"context_line":"* GET /servers?all_tenants\u003dTrue"},{"line_number":178,"context_line":""},{"line_number":179,"context_line":"  * scope check: {} (Note: this means check we are globally scoped)"},{"line_number":180,"context_line":"  * rule:admin_or_owner"},{"line_number":181,"context_line":""},{"line_number":182,"context_line":"* POST /servers"},{"line_number":183,"context_line":""}],"source_content_type":"text/x-rst","patch_set":16,"id":"1a1ced50_4aecfc29","line":180,"range":{"start_line":180,"start_character":4,"end_line":180,"end_character":23},"updated":"2017-03-22 21:47:39.000000000","message":"Are you changing the rule on this API because the default right now is rule:admin_api.","commit_id":"8b2e3c75e8543751e36b3c21685ec4e736ea2057"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"48d7d76d0ae4cacc76c7e05acca59207204ccff0","unresolved":false,"context_lines":[{"line_number":181,"context_line":""},{"line_number":182,"context_line":"* POST /servers"},{"line_number":183,"context_line":""},{"line_number":184,"context_line":"  * no scope check, anyone with the correct role can do this"},{"line_number":185,"context_line":"  * rule:admin_or_owner"},{"line_number":186,"context_line":""},{"line_number":187,"context_line":"* POST /servers/\u003cid\u003e/action {\"os-migrateLive\": {...}}"}],"source_content_type":"text/x-rst","patch_set":16,"id":"1a1ced50_4ad31c60","line":184,"range":{"start_line":184,"start_character":36,"end_line":184,"end_character":48},"updated":"2017-03-22 21:47:39.000000000","message":"What is an incorrect role?","commit_id":"8b2e3c75e8543751e36b3c21685ec4e736ea2057"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"48d7d76d0ae4cacc76c7e05acca59207204ccff0","unresolved":false,"context_lines":[{"line_number":198,"context_line":"* POST /flavors"},{"line_number":199,"context_line":""},{"line_number":200,"context_line":"  * scope check: {} (i.e. global, unless is a project specific flavor)"},{"line_number":201,"context_line":"  * rule:admin_api"},{"line_number":202,"context_line":""},{"line_number":203,"context_line":"Note the scope is not really specific to the API, its really specific to the"},{"line_number":204,"context_line":"object being changed such as the server (project scoped), keypair (user scope)"}],"source_content_type":"text/x-rst","patch_set":16,"id":"1a1ced50_0abe84fe","line":201,"range":{"start_line":201,"start_character":4,"end_line":201,"end_character":18},"updated":"2017-03-22 21:47:39.000000000","message":"Why wouldn\u0027t this be context_is_global_scope?","commit_id":"8b2e3c75e8543751e36b3c21685ec4e736ea2057"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"48d7d76d0ae4cacc76c7e05acca59207204ccff0","unresolved":false,"context_lines":[{"line_number":223,"context_line":"    \"os_compute_api:os-keypairs:index\": \"@\""},{"line_number":224,"context_line":""},{"line_number":225,"context_line":"    # This is a real check, so it stays as it is for now,"},{"line_number":226,"context_line":"    # we continue to pass in quota_class as a target, and"},{"line_number":227,"context_line":"    # we continue to check the quota_class in the context object"},{"line_number":228,"context_line":"    \"os_compute_api:os-quota-class-sets:show\":"},{"line_number":229,"context_line":"        \"is_admin:True or quota_class:%(quota_class)s\""}],"source_content_type":"text/x-rst","patch_set":16,"id":"1a1ced50_aa5ad0ef","line":226,"range":{"start_line":226,"start_character":46,"end_line":226,"end_character":52},"updated":"2017-03-22 21:47:39.000000000","message":"I didn\u0027t think we had targets anymore for the policy check, or what am I missing for this?","commit_id":"8b2e3c75e8543751e36b3c21685ec4e736ea2057"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"48d7d76d0ae4cacc76c7e05acca59207204ccff0","unresolved":false,"context_lines":[{"line_number":224,"context_line":""},{"line_number":225,"context_line":"    # This is a real check, so it stays as it is for now,"},{"line_number":226,"context_line":"    # we continue to pass in quota_class as a target, and"},{"line_number":227,"context_line":"    # we continue to check the quota_class in the context object"},{"line_number":228,"context_line":"    \"os_compute_api:os-quota-class-sets:show\":"},{"line_number":229,"context_line":"        \"is_admin:True or quota_class:%(quota_class)s\""},{"line_number":230,"context_line":""}],"source_content_type":"text/x-rst","patch_set":16,"id":"1a1ced50_0a03e4b8","line":227,"range":{"start_line":227,"start_character":6,"end_line":227,"end_character":64},"updated":"2017-03-22 21:47:39.000000000","message":"The quota_class in the context object is completely useless as far as I know, and we could remove it today with no consequence. Is it only there for some weird policy check?","commit_id":"8b2e3c75e8543751e36b3c21685ec4e736ea2057"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"48d7d76d0ae4cacc76c7e05acca59207204ccff0","unresolved":false,"context_lines":[{"line_number":252,"context_line":"We can\u0027t remove it right away, as it will break all existing policy files"},{"line_number":253,"context_line":"that people use in production."},{"line_number":254,"context_line":""},{"line_number":255,"context_line":"Note, there are some APIs that pass a target explicitly to allow admins to"},{"line_number":256,"context_line":"restrict the policy to the user_id of the server creator. We should not"},{"line_number":257,"context_line":"remove that ability during these changes."},{"line_number":258,"context_line":""},{"line_number":259,"context_line":"Remove \"discoverable\" rules"},{"line_number":260,"context_line":"---------------------------"}],"source_content_type":"text/x-rst","patch_set":16,"id":"1a1ced50_aab650f6","line":257,"range":{"start_line":255,"start_character":0,"end_line":257,"end_character":41},"updated":"2017-03-22 21:47:39.000000000","message":"Might be nice to give an example of this, i.e. the changePassword server action looks up the instance and then passes the instance.project_id and instance.user_id as the target to the context.can method for the check:\n\nhttps://git.openstack.org/cgit/openstack/nova/tree/nova/api/openstack/compute/admin_password.py?id\u003d1585ca189eb6e194441f9dff94c7a710d96e1acc#n47","commit_id":"8b2e3c75e8543751e36b3c21685ec4e736ea2057"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"48d7d76d0ae4cacc76c7e05acca59207204ccff0","unresolved":false,"context_lines":[{"line_number":280,"context_line":"obscure security issues. It is also makes for a much simpler policy file"},{"line_number":281,"context_line":"when there is no need to consider the scope of operations in the policy file."},{"line_number":282,"context_line":""},{"line_number":283,"context_line":"Its possible patrole gives reasonable RBAC coverage, but good functional tests"},{"line_number":284,"context_line":"in tree will help with all the work on related specs, such as those looking to"},{"line_number":285,"context_line":"add a distinction between read, write, and administrator APIs."},{"line_number":286,"context_line":""}],"source_content_type":"text/x-rst","patch_set":16,"id":"1a1ced50_8aaa7483","line":283,"range":{"start_line":283,"start_character":13,"end_line":283,"end_character":20},"updated":"2017-03-22 21:47:39.000000000","message":"You should link a reference to this for context:\n\nhttps://github.com/openstack/patrole","commit_id":"8b2e3c75e8543751e36b3c21685ec4e736ea2057"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"48d7d76d0ae4cacc76c7e05acca59207204ccff0","unresolved":false,"context_lines":[{"line_number":314,"context_line":"Performance Impact"},{"line_number":315,"context_line":"------------------"},{"line_number":316,"context_line":""},{"line_number":317,"context_line":"None"},{"line_number":318,"context_line":""},{"line_number":319,"context_line":"Other deployer impact"},{"line_number":320,"context_line":"---------------------"}],"source_content_type":"text/x-rst","patch_set":16,"id":"1a1ced50_ea7a0823","line":317,"updated":"2017-03-22 21:47:39.000000000","message":"If I\u0027m understanding the proposed change, don\u0027t we start having a lot more APIs where we need to look up a resource first, like a server, to get it\u0027s project_id (and possibly user_id) and pass those for the \u0027scope\u0027 parameter in the check_scope() method? Which means we\u0027re doing a lot more upfront lookup of resources from the database before being able to tell if you don\u0027t have access to something? Or were we always paying for this anyway, but would just fail in a different place (the model_query in the DB API)?","commit_id":"8b2e3c75e8543751e36b3c21685ec4e736ea2057"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"48d7d76d0ae4cacc76c7e05acca59207204ccff0","unresolved":false,"context_lines":[{"line_number":343,"context_line":""},{"line_number":344,"context_line":"* Remove \"discoverable\" extension rules"},{"line_number":345,"context_line":"* For each API file: First add functional tests. Then make use of"},{"line_number":346,"context_line":"  ``context.check_scope`` to check the scope and bypass the DB check."},{"line_number":347,"context_line":"* Once above completed, update the default policy rules so its clear"},{"line_number":348,"context_line":"  by default scope checks are no longer done in policy."},{"line_number":349,"context_line":"* Then add warnings for deployers that have a policy override that checks"}],"source_content_type":"text/x-rst","patch_set":16,"id":"1a1ced50_6abc58bb","line":346,"range":{"start_line":346,"start_character":45,"end_line":346,"end_character":69},"updated":"2017-03-22 21:47:39.000000000","message":"Doesn\u0027t the DB check happen as part of model_query? If so, and you need the actual resource to pass the resource.project_id to the scope variable of check_scope, then don\u0027t you first have to lookup the resource from the DB, which goes through the model_query? So a catch-22?","commit_id":"8b2e3c75e8543751e36b3c21685ec4e736ea2057"},{"author":{"_account_id":19590,"name":"Sarafraj Singh","email":"Sarafraj.Singh@intel.com","username":"sarafrajsingh"},"change_message_id":"e98beafbe7a0730d11a21c109eca5e38c49cc6b2","unresolved":false,"context_lines":[{"line_number":35,"context_line":"These rules, in turn evaluate based on information available from the"},{"line_number":36,"context_line":"oslo.context from keystone. They can be quite complicated."},{"line_number":37,"context_line":""},{"line_number":38,"context_line":"It is also is confusing and error prone. Some of these rules apply"},{"line_number":39,"context_line":"generally i.e. ``is_admin:True``, or ``role:admin``. But others"},{"line_number":40,"context_line":"require a target to operate on,"},{"line_number":41,"context_line":"i.e. ``project_id:%(project_id)s``. That evaluates to true if the"}],"source_content_type":"text/x-rst","patch_set":19,"id":"ffe62b97_69ef121e","line":38,"range":{"start_line":38,"start_character":3,"end_line":38,"end_character":13},"updated":"2017-03-28 18:00:34.000000000","message":"is","commit_id":"fb2f316719669d1f2cc49e0b1412ec72963a2622"},{"author":{"_account_id":20217,"name":"Anusha Unnam","email":"anusha.unnam25@gmail.com","username":"aunnam"},"change_message_id":"d898eddd734300dd741126236e592c8b99813e3b","unresolved":false,"context_lines":[{"line_number":52,"context_line":""},{"line_number":53,"context_line":"  \"os_compute_api:os-lock-server:lock\": \"rule:admin_or_owner or role:service\""},{"line_number":54,"context_line":""},{"line_number":55,"context_line":"However... this does not work as expected. Because the actual flow is"},{"line_number":56,"context_line":"as follows."},{"line_number":57,"context_line":""},{"line_number":58,"context_line":"- Attempt to fetch server in question"}],"source_content_type":"text/x-rst","patch_set":19,"id":"ffe62b97_8e80eaf6","line":55,"range":{"start_line":55,"start_character":11,"end_line":55,"end_character":41},"updated":"2017-03-29 14:45:52.000000000","message":"According to my understanding, this means for role:service it won\u0027t actually get any servers returned from db,  as is_admin: False and it can\u0027t fetch servers by project_id. I think some more explanation is needed here on why it doesn\u0027t work as expected.","commit_id":"fb2f316719669d1f2cc49e0b1412ec72963a2622"},{"author":{"_account_id":18337,"name":"Sujitha","email":"sujitha.neti@intel.com","username":"Sujitha"},"change_message_id":"a9ac0d2f73284bcf55ddf15c35996a18a7e01b23","unresolved":false,"context_lines":[{"line_number":52,"context_line":""},{"line_number":53,"context_line":"  \"os_compute_api:os-lock-server:lock\": \"rule:admin_or_owner or role:service\""},{"line_number":54,"context_line":""},{"line_number":55,"context_line":"However... this does not work as expected. Because the actual flow is"},{"line_number":56,"context_line":"as follows."},{"line_number":57,"context_line":""},{"line_number":58,"context_line":"- Attempt to fetch server in question"}],"source_content_type":"text/x-rst","patch_set":19,"id":"ffe62b97_c6fb6bbb","line":55,"range":{"start_line":55,"start_character":11,"end_line":55,"end_character":41},"in_reply_to":"ffe62b97_8e80eaf6","updated":"2017-03-29 19:55:20.000000000","message":"+1","commit_id":"fb2f316719669d1f2cc49e0b1412ec72963a2622"},{"author":{"_account_id":782,"name":"John Garbutt","email":"john@johngarbutt.com","username":"johngarbutt"},"change_message_id":"106dd65e6aa3f209837b4eb914644ecbef931ed4","unresolved":false,"context_lines":[{"line_number":52,"context_line":""},{"line_number":53,"context_line":"  \"os_compute_api:os-lock-server:lock\": \"rule:admin_or_owner or role:service\""},{"line_number":54,"context_line":""},{"line_number":55,"context_line":"However... this does not work as expected. Because the actual flow is"},{"line_number":56,"context_line":"as follows."},{"line_number":57,"context_line":""},{"line_number":58,"context_line":"- Attempt to fetch server in question"}],"source_content_type":"text/x-rst","patch_set":19,"id":"ffe62b97_761d5872","line":55,"range":{"start_line":55,"start_character":11,"end_line":55,"end_character":41},"in_reply_to":"ffe62b97_c6fb6bbb","updated":"2017-03-30 10:35:20.000000000","message":"the bullet list is trying to do that, I can expand that a little bit.","commit_id":"fb2f316719669d1f2cc49e0b1412ec72963a2622"},{"author":{"_account_id":19590,"name":"Sarafraj Singh","email":"Sarafraj.Singh@intel.com","username":"sarafrajsingh"},"change_message_id":"e98beafbe7a0730d11a21c109eca5e38c49cc6b2","unresolved":false,"context_lines":[{"line_number":56,"context_line":"as follows."},{"line_number":57,"context_line":""},{"line_number":58,"context_line":"- Attempt to fetch server in question"},{"line_number":59,"context_line":"- If not \"is_admin:True\", filter available servers by project_id of"},{"line_number":60,"context_line":"  token"},{"line_number":61,"context_line":"- If a server is returned, apply policy rules against that server"},{"line_number":62,"context_line":""}],"source_content_type":"text/x-rst","patch_set":19,"id":"ffe62b97_e971e277","line":59,"range":{"start_line":59,"start_character":9,"end_line":59,"end_character":24},"updated":"2017-03-28 18:00:34.000000000","message":"wrong quotes","commit_id":"fb2f316719669d1f2cc49e0b1412ec72963a2622"},{"author":{"_account_id":18337,"name":"Sujitha","email":"sujitha.neti@intel.com","username":"Sujitha"},"change_message_id":"a9ac0d2f73284bcf55ddf15c35996a18a7e01b23","unresolved":false,"context_lines":[{"line_number":60,"context_line":"  token"},{"line_number":61,"context_line":"- If a server is returned, apply policy rules against that server"},{"line_number":62,"context_line":""},{"line_number":63,"context_line":"Which basically means that elements of \"admin_or_owner\" are embedded"},{"line_number":64,"context_line":"deep in the database layer and nobs that look like they are changeable"},{"line_number":65,"context_line":"in policy are not."},{"line_number":66,"context_line":""}],"source_content_type":"text/x-rst","patch_set":19,"id":"ffe62b97_66db7f4e","line":63,"range":{"start_line":63,"start_character":27,"end_line":63,"end_character":39},"updated":"2017-03-29 19:55:20.000000000","message":"can we say: project check for admin_or_owner","commit_id":"fb2f316719669d1f2cc49e0b1412ec72963a2622"},{"author":{"_account_id":20217,"name":"Anusha Unnam","email":"anusha.unnam25@gmail.com","username":"aunnam"},"change_message_id":"d898eddd734300dd741126236e592c8b99813e3b","unresolved":false,"context_lines":[{"line_number":60,"context_line":"  token"},{"line_number":61,"context_line":"- If a server is returned, apply policy rules against that server"},{"line_number":62,"context_line":""},{"line_number":63,"context_line":"Which basically means that elements of \"admin_or_owner\" are embedded"},{"line_number":64,"context_line":"deep in the database layer and nobs that look like they are changeable"},{"line_number":65,"context_line":"in policy are not."},{"line_number":66,"context_line":""},{"line_number":67,"context_line":"This is the equivalent of issues that arise on a Linux filesystem if"}],"source_content_type":"text/x-rst","patch_set":19,"id":"ffe62b97_ee7e56e2","line":64,"range":{"start_line":63,"start_character":0,"end_line":64,"end_character":26},"updated":"2017-03-29 14:45:52.000000000","message":"In the last patch, there is an example for DB code to show DB level check, I think its good to include that here.","commit_id":"fb2f316719669d1f2cc49e0b1412ec72963a2622"},{"author":{"_account_id":20217,"name":"Anusha Unnam","email":"anusha.unnam25@gmail.com","username":"aunnam"},"change_message_id":"d898eddd734300dd741126236e592c8b99813e3b","unresolved":false,"context_lines":[{"line_number":61,"context_line":"- If a server is returned, apply policy rules against that server"},{"line_number":62,"context_line":""},{"line_number":63,"context_line":"Which basically means that elements of \"admin_or_owner\" are embedded"},{"line_number":64,"context_line":"deep in the database layer and nobs that look like they are changeable"},{"line_number":65,"context_line":"in policy are not."},{"line_number":66,"context_line":""},{"line_number":67,"context_line":"This is the equivalent of issues that arise on a Linux filesystem if"},{"line_number":68,"context_line":"the adminstrator leaves the permissions of a file as 775, but then"}],"source_content_type":"text/x-rst","patch_set":19,"id":"ffe62b97_cea392ff","line":65,"range":{"start_line":64,"start_character":31,"end_line":65,"end_character":18},"updated":"2017-03-29 14:45:52.000000000","message":"This sentence reads confusing.","commit_id":"fb2f316719669d1f2cc49e0b1412ec72963a2622"},{"author":{"_account_id":18337,"name":"Sujitha","email":"sujitha.neti@intel.com","username":"Sujitha"},"change_message_id":"a9ac0d2f73284bcf55ddf15c35996a18a7e01b23","unresolved":false,"context_lines":[{"line_number":70,"context_line":"thinks that they can change things, but it fails because there is a"},{"line_number":71,"context_line":"different level of protection that\u0027s not easily discoverable."},{"line_number":72,"context_line":""},{"line_number":73,"context_line":"The breaks the principle of least surprise."},{"line_number":74,"context_line":""},{"line_number":75,"context_line":"Consider an API, such as the show server API, that doesn\u0027t pass any"},{"line_number":76,"context_line":"target to the policy check but still uses the ``rule:admin_or_owner``"}],"source_content_type":"text/x-rst","patch_set":19,"id":"ffe62b97_a6018707","line":73,"range":{"start_line":73,"start_character":0,"end_line":73,"end_character":3},"updated":"2017-03-29 19:55:20.000000000","message":"This","commit_id":"fb2f316719669d1f2cc49e0b1412ec72963a2622"},{"author":{"_account_id":18337,"name":"Sujitha","email":"sujitha.neti@intel.com","username":"Sujitha"},"change_message_id":"a9ac0d2f73284bcf55ddf15c35996a18a7e01b23","unresolved":false,"context_lines":[{"line_number":77,"context_line":"policy rule:"},{"line_number":78,"context_line":"https://git.openstack.org/cgit/openstack/nova/tree/nova/api/openstack/compute/servers.py?id\u003dcec2802155a9041a80551b6a2e2fcdce0a843c2f#n520"},{"line_number":79,"context_line":""},{"line_number":80,"context_line":"Nova actually uses the following default target:"},{"line_number":81,"context_line":""},{"line_number":82,"context_line":"    target \u003d {\"user_id\": context.user_id, \"project_id\": context.project_id}"},{"line_number":83,"context_line":""}],"source_content_type":"text/x-rst","patch_set":19,"id":"ffe62b97_86a683c0","line":80,"range":{"start_line":80,"start_character":5,"end_line":80,"end_character":13},"updated":"2017-03-29 19:55:20.000000000","message":"currently?","commit_id":"fb2f316719669d1f2cc49e0b1412ec72963a2622"},{"author":{"_account_id":20217,"name":"Anusha Unnam","email":"anusha.unnam25@gmail.com","username":"aunnam"},"change_message_id":"d898eddd734300dd741126236e592c8b99813e3b","unresolved":false,"context_lines":[{"line_number":84,"context_line":"Putting the default target and the ``admin_or_owner`` rule together, we"},{"line_number":85,"context_line":"are actually doing this check on the context object:"},{"line_number":86,"context_line":""},{"line_number":87,"context_line":"    (\"admin\" in context.roles) or (context.project_id \u003d\u003d contect.project_id)"},{"line_number":88,"context_line":""},{"line_number":89,"context_line":"This always evaluates to True. This means anyone can access that API."},{"line_number":90,"context_line":"The hard coded database checks, however, ensure that you can only access the"}],"source_content_type":"text/x-rst","patch_set":19,"id":"ffe62b97_ee9ad611","line":87,"range":{"start_line":87,"start_character":57,"end_line":87,"end_character":64},"updated":"2017-03-29 14:45:52.000000000","message":"context","commit_id":"fb2f316719669d1f2cc49e0b1412ec72963a2622"},{"author":{"_account_id":18337,"name":"Sujitha","email":"sujitha.neti@intel.com","username":"Sujitha"},"change_message_id":"a9ac0d2f73284bcf55ddf15c35996a18a7e01b23","unresolved":false,"context_lines":[{"line_number":111,"context_line":"In Nova we want to scope servers to a project and keypairs to a user."},{"line_number":112,"context_line":"In the API, when you tried to access or modify a resource, we want to"},{"line_number":113,"context_line":"ensure the scope of the users token, as described in the context, matches"},{"line_number":114,"context_line":"the scope of the resource (such as a server or keyapir) that is being"},{"line_number":115,"context_line":"accessed."},{"line_number":116,"context_line":""},{"line_number":117,"context_line":"In addition, there is a special case where a token has a \"global\" scope,"}],"source_content_type":"text/x-rst","patch_set":19,"id":"ffe62b97_066a7318","line":114,"range":{"start_line":114,"start_character":47,"end_line":114,"end_character":54},"updated":"2017-03-29 19:55:20.000000000","message":"keypair","commit_id":"fb2f316719669d1f2cc49e0b1412ec72963a2622"},{"author":{"_account_id":20217,"name":"Anusha Unnam","email":"anusha.unnam25@gmail.com","username":"aunnam"},"change_message_id":"d898eddd734300dd741126236e592c8b99813e3b","unresolved":false,"context_lines":[{"line_number":123,"context_line":"------------------------------------------"},{"line_number":124,"context_line":""},{"line_number":125,"context_line":"A \"global context\" is a context that has access to all resources, regardless"},{"line_number":126,"context_line":"of the project_id or user_id associated with that resource. We current check"},{"line_number":127,"context_line":"to see if the context is \"global\" or not in both the ``admin_or_owner`` rule"},{"line_number":128,"context_line":"and the database checks around project_ids:"},{"line_number":129,"context_line":"https://git.openstack.org/cgit/openstack/nova/tree/nova/db/sqlalchemy/api.py?id\u003dcec2802155a9041a80551b6a2e2fcdce0a843c2f#n323"}],"source_content_type":"text/x-rst","patch_set":19,"id":"ffe62b97_49341cde","line":126,"range":{"start_line":126,"start_character":63,"end_line":126,"end_character":70},"updated":"2017-03-29 14:45:52.000000000","message":"currently","commit_id":"fb2f316719669d1f2cc49e0b1412ec72963a2622"},{"author":{"_account_id":20217,"name":"Anusha Unnam","email":"anusha.unnam25@gmail.com","username":"aunnam"},"change_message_id":"d898eddd734300dd741126236e592c8b99813e3b","unresolved":false,"context_lines":[{"line_number":126,"context_line":"of the project_id or user_id associated with that resource. We current check"},{"line_number":127,"context_line":"to see if the context is \"global\" or not in both the ``admin_or_owner`` rule"},{"line_number":128,"context_line":"and the database checks around project_ids:"},{"line_number":129,"context_line":"https://git.openstack.org/cgit/openstack/nova/tree/nova/db/sqlalchemy/api.py?id\u003dcec2802155a9041a80551b6a2e2fcdce0a843c2f#n323"},{"line_number":130,"context_line":""},{"line_number":131,"context_line":"Currently, we assume any context that passes ``\"is_admin\": \"role:admin\"`` (or"},{"line_number":132,"context_line":"whatever the policy file says) is a global context."}],"source_content_type":"text/x-rst","patch_set":19,"id":"ffe62b97_099e14b8","line":129,"range":{"start_line":129,"start_character":0,"end_line":129,"end_character":32},"updated":"2017-03-29 14:45:52.000000000","message":"here is the code for DB level check. Ignore my previous comment.","commit_id":"fb2f316719669d1f2cc49e0b1412ec72963a2622"},{"author":{"_account_id":782,"name":"John Garbutt","email":"john@johngarbutt.com","username":"johngarbutt"},"change_message_id":"106dd65e6aa3f209837b4eb914644ecbef931ed4","unresolved":false,"context_lines":[{"line_number":126,"context_line":"of the project_id or user_id associated with that resource. We current check"},{"line_number":127,"context_line":"to see if the context is \"global\" or not in both the ``admin_or_owner`` rule"},{"line_number":128,"context_line":"and the database checks around project_ids:"},{"line_number":129,"context_line":"https://git.openstack.org/cgit/openstack/nova/tree/nova/db/sqlalchemy/api.py?id\u003dcec2802155a9041a80551b6a2e2fcdce0a843c2f#n323"},{"line_number":130,"context_line":""},{"line_number":131,"context_line":"Currently, we assume any context that passes ``\"is_admin\": \"role:admin\"`` (or"},{"line_number":132,"context_line":"whatever the policy file says) is a global context."}],"source_content_type":"text/x-rst","patch_set":19,"id":"ffe62b97_315a3a2a","line":129,"range":{"start_line":129,"start_character":0,"end_line":129,"end_character":32},"in_reply_to":"ffe62b97_099e14b8","updated":"2017-03-30 10:35:20.000000000","message":"We could add the link in both places.","commit_id":"fb2f316719669d1f2cc49e0b1412ec72963a2622"},{"author":{"_account_id":18337,"name":"Sujitha","email":"sujitha.neti@intel.com","username":"Sujitha"},"change_message_id":"a9ac0d2f73284bcf55ddf15c35996a18a7e01b23","unresolved":false,"context_lines":[{"line_number":134,"context_line":"This causes a problem when an operator wants to give one user in each project"},{"line_number":135,"context_line":"access to all the admin operations, like live-migration. Generally they don\u0027t"},{"line_number":136,"context_line":"want that user to have a global context that is able to live-migrate any VM in"},{"line_number":137,"context_line":"the whole cloud. This is what happens to day if they have that user the admin"},{"line_number":138,"context_line":"role."},{"line_number":139,"context_line":""},{"line_number":140,"context_line":"Keystone has introduced the concept of ``is_admin_project``. When that is"}],"source_content_type":"text/x-rst","patch_set":19,"id":"ffe62b97_2679f7c6","line":137,"range":{"start_line":137,"start_character":38,"end_line":137,"end_character":44},"updated":"2017-03-29 19:55:20.000000000","message":"today","commit_id":"fb2f316719669d1f2cc49e0b1412ec72963a2622"},{"author":{"_account_id":18337,"name":"Sujitha","email":"sujitha.neti@intel.com","username":"Sujitha"},"change_message_id":"a9ac0d2f73284bcf55ddf15c35996a18a7e01b23","unresolved":false,"context_lines":[{"line_number":141,"context_line":"``True`` it means the context.project_id is the \"special\" admin project that"},{"line_number":142,"context_line":"means your token should be considered \"global\"."},{"line_number":143,"context_line":""},{"line_number":144,"context_line":"If we use ``is_admin_project`` to decide if the server project_id must match"},{"line_number":145,"context_line":"the context project_id or not, if an operator gives the admin role to a user"},{"line_number":146,"context_line":"in a project that isn\u0027t the special admin project, they no longer automatically"},{"line_number":147,"context_line":"have access to all resources in Nova."},{"line_number":148,"context_line":""}],"source_content_type":"text/x-rst","patch_set":19,"id":"ffe62b97_fc1f22b4","line":145,"range":{"start_line":144,"start_character":0,"end_line":145,"end_character":30},"updated":"2017-03-29 19:55:20.000000000","message":"I\u0027m not sure if I get this correctly. Maybe this need rephrasing.\n\nis_admin_project evaluates to true if server.project_id doesn\u0027t not match context.project_ id right?","commit_id":"fb2f316719669d1f2cc49e0b1412ec72963a2622"},{"author":{"_account_id":20217,"name":"Anusha Unnam","email":"anusha.unnam25@gmail.com","username":"aunnam"},"change_message_id":"6137c590fd32df46f9d4c222799b42b6888dbe2f","unresolved":false,"context_lines":[{"line_number":141,"context_line":"``True`` it means the context.project_id is the \"special\" admin project that"},{"line_number":142,"context_line":"means your token should be considered \"global\"."},{"line_number":143,"context_line":""},{"line_number":144,"context_line":"If we use ``is_admin_project`` to decide if the server project_id must match"},{"line_number":145,"context_line":"the context project_id or not, if an operator gives the admin role to a user"},{"line_number":146,"context_line":"in a project that isn\u0027t the special admin project, they no longer automatically"},{"line_number":147,"context_line":"have access to all resources in Nova."},{"line_number":148,"context_line":""}],"source_content_type":"text/x-rst","patch_set":19,"id":"ffe62b97_d7bd5402","line":145,"range":{"start_line":144,"start_character":0,"end_line":145,"end_character":30},"in_reply_to":"ffe62b97_fc1f22b4","updated":"2017-03-29 22:14:11.000000000","message":"I think its the opposite.\nIf is_admin_project\u003dTrue, then project_id doesn\u0027t need to match context project_id.\n\nSo, if server.project_id doesn\u0027t not match context.project_ id then we check is_admin_project, if it is true: then we consider it as global scope, if it is false: then user has no access to that resource.","commit_id":"fb2f316719669d1f2cc49e0b1412ec72963a2622"},{"author":{"_account_id":19590,"name":"Sarafraj Singh","email":"Sarafraj.Singh@intel.com","username":"sarafrajsingh"},"change_message_id":"e98beafbe7a0730d11a21c109eca5e38c49cc6b2","unresolved":false,"context_lines":[{"line_number":170,"context_line":"policy layer, and replace them with a new explicit (and still hardcoded) scope"},{"line_number":171,"context_line":"check."},{"line_number":172,"context_line":""},{"line_number":173,"context_line":"To remove the database later check, we can take these steps:"},{"line_number":174,"context_line":""},{"line_number":175,"context_line":"* In the API use context.elevated() for all DB calls to bypass the project"},{"line_number":176,"context_line":"  checks in the database logic."}],"source_content_type":"text/x-rst","patch_set":19,"id":"ffe62b97_24a12f47","line":173,"range":{"start_line":173,"start_character":23,"end_line":173,"end_character":34},"updated":"2017-03-28 18:00:34.000000000","message":"check","commit_id":"fb2f316719669d1f2cc49e0b1412ec72963a2622"},{"author":{"_account_id":20217,"name":"Anusha Unnam","email":"anusha.unnam25@gmail.com","username":"aunnam"},"change_message_id":"ae7fa11d19a2ddb3243aead659b638871c3a0da4","unresolved":false,"context_lines":[{"line_number":177,"context_line":"* Once we have all APIs protected by the explicit scope check, we can consider"},{"line_number":178,"context_line":"  dropping all the scope checks in the database."},{"line_number":179,"context_line":""},{"line_number":180,"context_line":"To remove the policy layer checks:"},{"line_number":181,"context_line":""},{"line_number":182,"context_line":"* Once all scope checks are in place, ``admin_or_owner`` is defaulted to ``@``"},{"line_number":183,"context_line":"  which means anyone can access that API."}],"source_content_type":"text/x-rst","patch_set":19,"id":"ffe62b97_69423d11","line":180,"range":{"start_line":180,"start_character":3,"end_line":180,"end_character":33},"updated":"2017-03-29 15:26:41.000000000","message":"After we remove scope checks from policy, then the policy only checks for roles, which is now just admin role. So its nice to add here that later on we are going to add more roles which is mentioned in your other spec.","commit_id":"fb2f316719669d1f2cc49e0b1412ec72963a2622"},{"author":{"_account_id":18337,"name":"Sujitha","email":"sujitha.neti@intel.com","username":"Sujitha"},"change_message_id":"a9ac0d2f73284bcf55ddf15c35996a18a7e01b23","unresolved":false,"context_lines":[{"line_number":181,"context_line":""},{"line_number":182,"context_line":"* Once all scope checks are in place, ``admin_or_owner`` is defaulted to ``@``"},{"line_number":183,"context_line":"  which means anyone can access that API."},{"line_number":184,"context_line":"* Note: we keep ``admin_or_owner`` for once cycle to allow for a smooth"},{"line_number":185,"context_line":"  upgrade experience. After which time we can rename the rule to something"},{"line_number":186,"context_line":"  more appropriate."},{"line_number":187,"context_line":"* Longer term we can remove the target passed into any policy checks, so"}],"source_content_type":"text/x-rst","patch_set":19,"id":"ffe62b97_61a00943","line":184,"range":{"start_line":184,"start_character":39,"end_line":184,"end_character":43},"updated":"2017-03-29 19:55:20.000000000","message":"one","commit_id":"fb2f316719669d1f2cc49e0b1412ec72963a2622"},{"author":{"_account_id":20217,"name":"Anusha Unnam","email":"anusha.unnam25@gmail.com","username":"aunnam"},"change_message_id":"cede07cee3eb86446371281f2603cab4a271155e","unresolved":false,"context_lines":[{"line_number":146,"context_line":""},{"line_number":147,"context_line":"Keystone has introduced the concept of ``is_admin_project``. When that is"},{"line_number":148,"context_line":"``True`` it means the context.project_id is the \"special\" admin project."},{"line_number":149,"context_line":"The idea behind that features is when you have a token for that special"},{"line_number":150,"context_line":"project, the roles you have in that project apply \"globally\". Its possible"},{"line_number":151,"context_line":"those roles don\u0027t allow access to anything in Nova, but the token should"},{"line_number":152,"context_line":"bypass any project_id or user_id checks, because it should be considered"}],"source_content_type":"text/x-rst","patch_set":20,"id":"ffe62b97_3f3f95b6","line":149,"range":{"start_line":149,"start_character":21,"end_line":149,"end_character":29},"updated":"2017-03-30 15:42:15.000000000","message":"nit: s/features/feature","commit_id":"70bac1829a42445d8ecef9ae9038e88a970afebe"},{"author":{"_account_id":20217,"name":"Anusha Unnam","email":"anusha.unnam25@gmail.com","username":"aunnam"},"change_message_id":"cede07cee3eb86446371281f2603cab4a271155e","unresolved":false,"context_lines":[{"line_number":154,"context_line":""},{"line_number":155,"context_line":"Lets consider if we use ``is_admin_project`` in Nova to decide if we need to"},{"line_number":156,"context_line":"check if ``instance.project_id`` matches ``context.project_id`` or not."},{"line_number":157,"context_line":"This means if you get the admin role, you not longer automatically get access"},{"line_number":158,"context_line":"to all resources in the system, you only get the admin role applying to"},{"line_number":159,"context_line":"resources that match ``context.project_id``. If an operator assigns a user"},{"line_number":160,"context_line":"with a role in the special admin project that gives them read access in Nova,"}],"source_content_type":"text/x-rst","patch_set":20,"id":"ffe62b97_3f68b5b8","line":157,"range":{"start_line":157,"start_character":42,"end_line":157,"end_character":45},"updated":"2017-03-30 15:42:15.000000000","message":"nit: s/not/no","commit_id":"70bac1829a42445d8ecef9ae9038e88a970afebe"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"b8d1ab62ce7fbc17e3881dcc016c1a9d6424b1bc","unresolved":false,"context_lines":[{"line_number":30,"context_line":"policy file and it is not built into the policy system. For example this is"},{"line_number":31,"context_line":"the default for ``admin_or_owner``::"},{"line_number":32,"context_line":""},{"line_number":33,"context_line":"  \"admin_or_owner\":  \"is_admin:True or project_id:%(project_id)s\","},{"line_number":34,"context_line":""},{"line_number":35,"context_line":"These rules, in turn evaluate based on information available from the"},{"line_number":36,"context_line":"oslo.context from keystone. They can be quite complicated."}],"source_content_type":"text/x-rst","patch_set":21,"id":"9ff52f3f_ffc49f94","line":33,"updated":"2017-04-12 23:39:49.000000000","message":"https://docs.openstack.org/ocata/config-reference/policy-json-file.html says otherwise:\n\n\"admin_or_owner\": \"rule:admin_required or rule:owner\",\n\nAnd keystone says something else:\n\nhttps://github.com/openstack/keystone/blob/master/etc/policy.v3cloudsample.json#L7\n\n\"admin_or_owner\": \"(rule:admin_required and domain_id:%(target.token.user.domain.id)s) or rule:owner\",\n\nBTW, https://docs.openstack.org/developer/nova/sample_policy.html should probably be required reading before reading this spec. I had never read it before (didn\u0027t know it existed).\n\n--\n\nI found this later, I guess nova overrides this:\n\n\"admin_or_owner\": \"is_admin:True or project_id:%(project_id)s\"\n\nOh, and Lance pointed out that keystone sample is not what they use either, it\u0027s defined in code:\n\nhttps://github.com/openstack/keystone/blob/master/keystone/common/policies/base.py#L48\n\nSo I\u0027m just all sorts of mixed up.","commit_id":"2ce720bb89fd042e118c62532e2440e1a7369a5a"},{"author":{"_account_id":782,"name":"John Garbutt","email":"john@johngarbutt.com","username":"johngarbutt"},"change_message_id":"9807058d37e1f71d5136b9ae91ef210141ab4538","unresolved":false,"context_lines":[{"line_number":30,"context_line":"policy file and it is not built into the policy system. For example this is"},{"line_number":31,"context_line":"the default for ``admin_or_owner``::"},{"line_number":32,"context_line":""},{"line_number":33,"context_line":"  \"admin_or_owner\":  \"is_admin:True or project_id:%(project_id)s\","},{"line_number":34,"context_line":""},{"line_number":35,"context_line":"These rules, in turn evaluate based on information available from the"},{"line_number":36,"context_line":"oslo.context from keystone. They can be quite complicated."}],"source_content_type":"text/x-rst","patch_set":21,"id":"9ff52f3f_6b3f9fd6","line":33,"in_reply_to":"9ff52f3f_ffc49f94","updated":"2017-04-13 14:23:54.000000000","message":"Sounds like very bad docs.\n\nYou can see what is real in our generated docs:\nhttps://docs.openstack.org/developer/nova/sample_policy.html\n\nIts purely an arbitrary rule we have invented in Nova, that happens to use the same name other use.","commit_id":"2ce720bb89fd042e118c62532e2440e1a7369a5a"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"b8d1ab62ce7fbc17e3881dcc016c1a9d6424b1bc","unresolved":false,"context_lines":[{"line_number":36,"context_line":"oslo.context from keystone. They can be quite complicated."},{"line_number":37,"context_line":""},{"line_number":38,"context_line":"It is confusing and error prone. Some of these rules apply"},{"line_number":39,"context_line":"generally i.e. ``is_admin:True``, or ``role:admin``. But others"},{"line_number":40,"context_line":"require a target to operate on,"},{"line_number":41,"context_line":"i.e. ``project_id:%(project_id)s``. That evaluates to true if the"},{"line_number":42,"context_line":"project_id of the target matches the project_id in the context."},{"line_number":43,"context_line":""},{"line_number":44,"context_line":"Lets take the example of::"},{"line_number":45,"context_line":""}],"source_content_type":"text/x-rst","patch_set":21,"id":"9ff52f3f_1f450318","line":42,"range":{"start_line":39,"start_character":53,"end_line":42,"end_character":63},"updated":"2017-04-12 23:39:49.000000000","message":"\"target\" is kind of an internal term it seems. The policy doc linked above explains it well with an example I think:\n\nRules can compare API attributes to object attributes. For example:\n\n\"os_compute_api:servers:start\" : \"project_id:%(project_id)s\"\n\nstates that only the owner of an instance can start it up. The project_id string before the colon is an API attribute, namely the project ID of the API user. It is compared with the project ID of the object (in this case, an instance). More precisely, it is compared with the project_id field of that object in the database. If the two values are equal, permission is granted.\n\n--\n\nI\u0027m not saying you need to change anything here, but I like the way the policy doc phrases it and gives an example for context.\n\nLater on in L170 you call it \"API resource\", I think that\u0027s more clear than \u0027target\u0027.","commit_id":"2ce720bb89fd042e118c62532e2440e1a7369a5a"},{"author":{"_account_id":782,"name":"John Garbutt","email":"john@johngarbutt.com","username":"johngarbutt"},"change_message_id":"9807058d37e1f71d5136b9ae91ef210141ab4538","unresolved":false,"context_lines":[{"line_number":36,"context_line":"oslo.context from keystone. They can be quite complicated."},{"line_number":37,"context_line":""},{"line_number":38,"context_line":"It is confusing and error prone. Some of these rules apply"},{"line_number":39,"context_line":"generally i.e. ``is_admin:True``, or ``role:admin``. But others"},{"line_number":40,"context_line":"require a target to operate on,"},{"line_number":41,"context_line":"i.e. ``project_id:%(project_id)s``. That evaluates to true if the"},{"line_number":42,"context_line":"project_id of the target matches the project_id in the context."},{"line_number":43,"context_line":""},{"line_number":44,"context_line":"Lets take the example of::"},{"line_number":45,"context_line":""}],"source_content_type":"text/x-rst","patch_set":21,"id":"9ff52f3f_6b18bf80","line":42,"range":{"start_line":39,"start_character":53,"end_line":42,"end_character":63},"in_reply_to":"9ff52f3f_1f450318","updated":"2017-04-13 14:23:54.000000000","message":"\"target\" is just the parameter name we use in Nova, and I think oslo.policy.","commit_id":"2ce720bb89fd042e118c62532e2440e1a7369a5a"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"b8d1ab62ce7fbc17e3881dcc016c1a9d6424b1bc","unresolved":false,"context_lines":[{"line_number":61,"context_line":"* Because ``context.is_admin \u003d\u003d False`` the DB layer applies the filter"},{"line_number":62,"context_line":"  to ensure it only returns servers with a project_id that matches"},{"line_number":63,"context_line":"  ``context.project_id``"},{"line_number":64,"context_line":"  https://git.openstack.org/cgit/openstack/nova/tree/nova/db/sqlalchemy/api.py?id\u003dcec2802155a9041a80551b6a2e2fcdce0a843c2f#n323"},{"line_number":65,"context_line":"* As no server matches and triggers a 404 error. This all happens before"},{"line_number":66,"context_line":"  the policy is checked."},{"line_number":67,"context_line":""}],"source_content_type":"text/x-rst","patch_set":21,"id":"9ff52f3f_ffcedf81","line":64,"updated":"2017-04-12 23:39:49.000000000","message":"This has:\n\nif nova.context.is_user_context(context) and project_only:\n\nWhat is project_only set to in this case because project_only defaults to False.\n\nAh, project_only\u003dTrue here:\n\nhttps://git.openstack.org/cgit/openstack/nova/tree/nova/db/sqlalchemy/api.py?id\u003dcec2802155a9041a80551b6a2e2fcdce0a843c2f#n1934\n\nSo that\u0027s the key part, maybe you should also mention that 2nd link for the full story.\n\nFor listing instances, it\u0027s similar but not the same:\n\nhttps://git.openstack.org/cgit/openstack/nova/tree/nova/db/sqlalchemy/api.py?id\u003dcec2802155a9041a80551b6a2e2fcdce0a843c2f#n2031\n\nThat uses model_query but doesn\u0027t rely on project_only\u003dTrue. I\u0027m assuming that also needs to change?","commit_id":"2ce720bb89fd042e118c62532e2440e1a7369a5a"},{"author":{"_account_id":782,"name":"John Garbutt","email":"john@johngarbutt.com","username":"johngarbutt"},"change_message_id":"9807058d37e1f71d5136b9ae91ef210141ab4538","unresolved":false,"context_lines":[{"line_number":61,"context_line":"* Because ``context.is_admin \u003d\u003d False`` the DB layer applies the filter"},{"line_number":62,"context_line":"  to ensure it only returns servers with a project_id that matches"},{"line_number":63,"context_line":"  ``context.project_id``"},{"line_number":64,"context_line":"  https://git.openstack.org/cgit/openstack/nova/tree/nova/db/sqlalchemy/api.py?id\u003dcec2802155a9041a80551b6a2e2fcdce0a843c2f#n323"},{"line_number":65,"context_line":"* As no server matches and triggers a 404 error. This all happens before"},{"line_number":66,"context_line":"  the policy is checked."},{"line_number":67,"context_line":""}],"source_content_type":"text/x-rst","patch_set":21,"id":"9ff52f3f_a62cbe99","line":64,"in_reply_to":"9ff52f3f_ffcedf81","updated":"2017-04-13 14:23:54.000000000","message":"If that helps, I can add the second link.","commit_id":"2ce720bb89fd042e118c62532e2440e1a7369a5a"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"b8d1ab62ce7fbc17e3881dcc016c1a9d6424b1bc","unresolved":false,"context_lines":[{"line_number":62,"context_line":"  to ensure it only returns servers with a project_id that matches"},{"line_number":63,"context_line":"  ``context.project_id``"},{"line_number":64,"context_line":"  https://git.openstack.org/cgit/openstack/nova/tree/nova/db/sqlalchemy/api.py?id\u003dcec2802155a9041a80551b6a2e2fcdce0a843c2f#n323"},{"line_number":65,"context_line":"* As no server matches and triggers a 404 error. This all happens before"},{"line_number":66,"context_line":"  the policy is checked."},{"line_number":67,"context_line":""},{"line_number":68,"context_line":"Note how the project_id check in the ``admin_or_owner`` rule is actually"},{"line_number":69,"context_line":"embedded deep in the database layer. In the policy file it may look like"}],"source_content_type":"text/x-rst","patch_set":21,"id":"9ff52f3f_5f8eeb2e","line":66,"range":{"start_line":65,"start_character":49,"end_line":66,"end_character":24},"updated":"2017-04-12 23:39:49.000000000","message":"Maybe link to https://git.openstack.org/cgit/openstack/nova/tree/nova/api/openstack/compute/lock_server.py#n36 for the rest of that story - we fetch the instance before checking the policy, but fail to get the instance because of the above issue.","commit_id":"2ce720bb89fd042e118c62532e2440e1a7369a5a"},{"author":{"_account_id":782,"name":"John Garbutt","email":"john@johngarbutt.com","username":"johngarbutt"},"change_message_id":"9807058d37e1f71d5136b9ae91ef210141ab4538","unresolved":false,"context_lines":[{"line_number":62,"context_line":"  to ensure it only returns servers with a project_id that matches"},{"line_number":63,"context_line":"  ``context.project_id``"},{"line_number":64,"context_line":"  https://git.openstack.org/cgit/openstack/nova/tree/nova/db/sqlalchemy/api.py?id\u003dcec2802155a9041a80551b6a2e2fcdce0a843c2f#n323"},{"line_number":65,"context_line":"* As no server matches and triggers a 404 error. This all happens before"},{"line_number":66,"context_line":"  the policy is checked."},{"line_number":67,"context_line":""},{"line_number":68,"context_line":"Note how the project_id check in the ``admin_or_owner`` rule is actually"},{"line_number":69,"context_line":"embedded deep in the database layer. In the policy file it may look like"}],"source_content_type":"text/x-rst","patch_set":21,"id":"9ff52f3f_86565a06","line":66,"range":{"start_line":65,"start_character":49,"end_line":66,"end_character":24},"in_reply_to":"9ff52f3f_5f8eeb2e","updated":"2017-04-13 14:23:54.000000000","message":"Yeah, need a matching pair with above I guess.","commit_id":"2ce720bb89fd042e118c62532e2440e1a7369a5a"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"b8d1ab62ce7fbc17e3881dcc016c1a9d6424b1bc","unresolved":false,"context_lines":[{"line_number":65,"context_line":"* As no server matches and triggers a 404 error. This all happens before"},{"line_number":66,"context_line":"  the policy is checked."},{"line_number":67,"context_line":""},{"line_number":68,"context_line":"Note how the project_id check in the ``admin_or_owner`` rule is actually"},{"line_number":69,"context_line":"embedded deep in the database layer. In the policy file it may look like"},{"line_number":70,"context_line":"you could modify that check, in reality any relaxing of the project check"},{"line_number":71,"context_line":"in the policy file is overridden by the check in the database layer."},{"line_number":72,"context_line":""},{"line_number":73,"context_line":"This is the equivalent of issues that arise on a Linux filesystem if"},{"line_number":74,"context_line":"the administrator leaves the permissions of a file as 775, but then"}],"source_content_type":"text/x-rst","patch_set":21,"id":"9ff52f3f_bf76173e","line":71,"range":{"start_line":68,"start_character":0,"end_line":71,"end_character":68},"updated":"2017-04-12 23:39:49.000000000","message":"Yes, this makes sense now that I followed the links (some of which you need to add here).","commit_id":"2ce720bb89fd042e118c62532e2440e1a7369a5a"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"b8d1ab62ce7fbc17e3881dcc016c1a9d6424b1bc","unresolved":false,"context_lines":[{"line_number":76,"context_line":"thinks that they can change things, but it fails because there is a"},{"line_number":77,"context_line":"different level of protection that\u0027s not easily discoverable."},{"line_number":78,"context_line":""},{"line_number":79,"context_line":"This breaks the principle of least surprise."},{"line_number":80,"context_line":""},{"line_number":81,"context_line":"Consider an API, such as the show server API, that doesn\u0027t pass any"},{"line_number":82,"context_line":"target to the policy check but still uses the ``rule:admin_or_owner``"}],"source_content_type":"text/x-rst","patch_set":21,"id":"9ff52f3f_df9e7b53","line":79,"updated":"2017-04-12 23:39:49.000000000","message":"But it enforces the principle of hilarious consequences!","commit_id":"2ce720bb89fd042e118c62532e2440e1a7369a5a"},{"author":{"_account_id":782,"name":"John Garbutt","email":"john@johngarbutt.com","username":"johngarbutt"},"change_message_id":"9807058d37e1f71d5136b9ae91ef210141ab4538","unresolved":false,"context_lines":[{"line_number":76,"context_line":"thinks that they can change things, but it fails because there is a"},{"line_number":77,"context_line":"different level of protection that\u0027s not easily discoverable."},{"line_number":78,"context_line":""},{"line_number":79,"context_line":"This breaks the principle of least surprise."},{"line_number":80,"context_line":""},{"line_number":81,"context_line":"Consider an API, such as the show server API, that doesn\u0027t pass any"},{"line_number":82,"context_line":"target to the policy check but still uses the ``rule:admin_or_owner``"}],"source_content_type":"text/x-rst","patch_set":21,"id":"9ff52f3f_e6464650","line":79,"in_reply_to":"9ff52f3f_df9e7b53","updated":"2017-04-13 14:23:54.000000000","message":":)","commit_id":"2ce720bb89fd042e118c62532e2440e1a7369a5a"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"b8d1ab62ce7fbc17e3881dcc016c1a9d6424b1bc","unresolved":false,"context_lines":[{"line_number":95,"context_line":""},{"line_number":96,"context_line":"This always evaluates to True. This means anyone can access that API."},{"line_number":97,"context_line":"The hard coded database checks, however, ensure that you can only access the"},{"line_number":98,"context_line":"data in the database if your token allows you to."},{"line_number":99,"context_line":""},{"line_number":100,"context_line":"Use Cases"},{"line_number":101,"context_line":"---------"}],"source_content_type":"text/x-rst","patch_set":21,"id":"9ff52f3f_5f0a6b8a","line":98,"range":{"start_line":98,"start_character":29,"end_line":98,"end_character":34},"updated":"2017-04-12 23:39:49.000000000","message":"Because it compares the context.projet_id against the instance.project_id, right?","commit_id":"2ce720bb89fd042e118c62532e2440e1a7369a5a"},{"author":{"_account_id":782,"name":"John Garbutt","email":"john@johngarbutt.com","username":"johngarbutt"},"change_message_id":"9807058d37e1f71d5136b9ae91ef210141ab4538","unresolved":false,"context_lines":[{"line_number":95,"context_line":""},{"line_number":96,"context_line":"This always evaluates to True. This means anyone can access that API."},{"line_number":97,"context_line":"The hard coded database checks, however, ensure that you can only access the"},{"line_number":98,"context_line":"data in the database if your token allows you to."},{"line_number":99,"context_line":""},{"line_number":100,"context_line":"Use Cases"},{"line_number":101,"context_line":"---------"}],"source_content_type":"text/x-rst","patch_set":21,"id":"9ff52f3f_866f7ac4","line":98,"range":{"start_line":98,"start_character":29,"end_line":98,"end_character":34},"in_reply_to":"9ff52f3f_5f0a6b8a","updated":"2017-04-13 14:23:54.000000000","message":"yes, the context representing the details of what your token represents.","commit_id":"2ce720bb89fd042e118c62532e2440e1a7369a5a"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"b8d1ab62ce7fbc17e3881dcc016c1a9d6424b1bc","unresolved":false,"context_lines":[{"line_number":115,"context_line":"this comes from the fact you assign roles to users within the scope of a"},{"line_number":116,"context_line":"particular project."},{"line_number":117,"context_line":"The context is populated with this info when the token is validated."},{"line_number":118,"context_line":"In Nova we want to scope servers to a project and keypairs to a user."},{"line_number":119,"context_line":"In the API, when you tried to access or modify a resource, we want to"},{"line_number":120,"context_line":"ensure the scope of the users token, as described in the context, matches"},{"line_number":121,"context_line":"the scope of the resource (such as a server or keypair) that is being"}],"source_content_type":"text/x-rst","patch_set":21,"id":"9ff52f3f_5f2f0bf6","line":118,"range":{"start_line":118,"start_character":50,"end_line":118,"end_character":68},"updated":"2017-04-12 23:39:49.000000000","message":"i.e. \"os_compute_api:os-keypairs:create\": \"rule:admin_api or user_id:%(user_id)s\"","commit_id":"2ce720bb89fd042e118c62532e2440e1a7369a5a"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"b8d1ab62ce7fbc17e3881dcc016c1a9d6424b1bc","unresolved":false,"context_lines":[{"line_number":115,"context_line":"this comes from the fact you assign roles to users within the scope of a"},{"line_number":116,"context_line":"particular project."},{"line_number":117,"context_line":"The context is populated with this info when the token is validated."},{"line_number":118,"context_line":"In Nova we want to scope servers to a project and keypairs to a user."},{"line_number":119,"context_line":"In the API, when you tried to access or modify a resource, we want to"},{"line_number":120,"context_line":"ensure the scope of the users token, as described in the context, matches"},{"line_number":121,"context_line":"the scope of the resource (such as a server or keypair) that is being"}],"source_content_type":"text/x-rst","patch_set":21,"id":"9ff52f3f_7f2acfe7","line":118,"range":{"start_line":118,"start_character":25,"end_line":118,"end_character":45},"updated":"2017-04-12 23:39:49.000000000","message":"i.e. \"os_compute_api:servers:create\": \"rule:admin_or_owner\"\n\nBTW, this is a bit confusing because keystone defines rule:owner as:\n\n\"owner\" : \"user_id:%(user_id)s or user_id:%(target.token.user_id)s\",\n\nSo it\u0027s scoped to the user, not the project.\n\nSo:\n\n\"admin_or_owner\": \"(rule:admin_required and domain_id:%(target.token.user.domain.id)s) or rule:owner\",\n\n\u003d\n\n\"admin_required\": \"role:admin\", + \"owner\" : \"user_id:%(user_id)s or user_id:%(target.token.user_id)s\",\n\n--\n\nNevermind, I found out later that nova overrides the default in keystone with our own:\n\n\"admin_or_owner\": \"is_admin:True or project_id:%(project_id)s\"","commit_id":"2ce720bb89fd042e118c62532e2440e1a7369a5a"},{"author":{"_account_id":782,"name":"John Garbutt","email":"john@johngarbutt.com","username":"johngarbutt"},"change_message_id":"9807058d37e1f71d5136b9ae91ef210141ab4538","unresolved":false,"context_lines":[{"line_number":115,"context_line":"this comes from the fact you assign roles to users within the scope of a"},{"line_number":116,"context_line":"particular project."},{"line_number":117,"context_line":"The context is populated with this info when the token is validated."},{"line_number":118,"context_line":"In Nova we want to scope servers to a project and keypairs to a user."},{"line_number":119,"context_line":"In the API, when you tried to access or modify a resource, we want to"},{"line_number":120,"context_line":"ensure the scope of the users token, as described in the context, matches"},{"line_number":121,"context_line":"the scope of the resource (such as a server or keypair) that is being"}],"source_content_type":"text/x-rst","patch_set":21,"id":"9ff52f3f_06b80a28","line":118,"range":{"start_line":118,"start_character":25,"end_line":118,"end_character":45},"in_reply_to":"9ff52f3f_7f2acfe7","updated":"2017-04-13 14:23:54.000000000","message":"To be clear there is no \"default in keystone\", our rule set is independent. We just have confusingly different meaning for rules with the same name.","commit_id":"2ce720bb89fd042e118c62532e2440e1a7369a5a"},{"author":{"_account_id":11564,"name":"Chris Dent","email":"cdent@anticdent.org","username":"chdent"},"change_message_id":"15b9ad166dfce7532e0085e10975ae5510b0b761","unresolved":false,"context_lines":[{"line_number":119,"context_line":"In the API, when you tried to access or modify a resource, we want to"},{"line_number":120,"context_line":"ensure the scope of the users token, as described in the context, matches"},{"line_number":121,"context_line":"the scope of the resource (such as a server or keypair) that is being"},{"line_number":122,"context_line":"accessed."},{"line_number":123,"context_line":""},{"line_number":124,"context_line":"In addition, there is a special case where a token has a \"global\" scope,"},{"line_number":125,"context_line":"i.e. that token has access to all resources. Some resources are considered"}],"source_content_type":"text/x-rst","patch_set":21,"id":"dfeb2761_513785e4","line":122,"updated":"2017-04-04 11:25:44.000000000","message":"I keep reading this paragraph without success on extracting the full message. I expect to know in this paragraph what the proposed change is, but I don\u0027t.","commit_id":"2ce720bb89fd042e118c62532e2440e1a7369a5a"},{"author":{"_account_id":782,"name":"John Garbutt","email":"john@johngarbutt.com","username":"johngarbutt"},"change_message_id":"a9789548c4e6f3c14dd865868bbaf396a50dcadf","unresolved":false,"context_lines":[{"line_number":119,"context_line":"In the API, when you tried to access or modify a resource, we want to"},{"line_number":120,"context_line":"ensure the scope of the users token, as described in the context, matches"},{"line_number":121,"context_line":"the scope of the resource (such as a server or keypair) that is being"},{"line_number":122,"context_line":"accessed."},{"line_number":123,"context_line":""},{"line_number":124,"context_line":"In addition, there is a special case where a token has a \"global\" scope,"},{"line_number":125,"context_line":"i.e. that token has access to all resources. Some resources are considered"}],"source_content_type":"text/x-rst","patch_set":21,"id":"bff0334d_9fc12857","line":122,"in_reply_to":"bff0334d_46d9a91f","updated":"2017-04-12 13:05:04.000000000","message":"@alex, thats true, that maybe got lost in the most recent translation.","commit_id":"2ce720bb89fd042e118c62532e2440e1a7369a5a"},{"author":{"_account_id":5754,"name":"Alex Xu","email":"hejie.xu@intel.com","username":"xuhj"},"change_message_id":"d6c25cda175d9bc388e5818a83dcddd04262f0ef","unresolved":false,"context_lines":[{"line_number":119,"context_line":"In the API, when you tried to access or modify a resource, we want to"},{"line_number":120,"context_line":"ensure the scope of the users token, as described in the context, matches"},{"line_number":121,"context_line":"the scope of the resource (such as a server or keypair) that is being"},{"line_number":122,"context_line":"accessed."},{"line_number":123,"context_line":""},{"line_number":124,"context_line":"In addition, there is a special case where a token has a \"global\" scope,"},{"line_number":125,"context_line":"i.e. that token has access to all resources. Some resources are considered"}],"source_content_type":"text/x-rst","patch_set":21,"id":"bff0334d_46d9a91f","line":122,"in_reply_to":"dfeb2761_2c0b5a7d","updated":"2017-04-12 07:58:08.000000000","message":"@John, Sounds like the \"problem section only talk about the problem of db layer owner check. It didn\u0027t talk about the problem of mix the role check and scope check into single policy rule.","commit_id":"2ce720bb89fd042e118c62532e2440e1a7369a5a"},{"author":{"_account_id":782,"name":"John Garbutt","email":"john@johngarbutt.com","username":"johngarbutt"},"change_message_id":"2e450a09a955110e64773108a7b5077b7f8d4b65","unresolved":false,"context_lines":[{"line_number":119,"context_line":"In the API, when you tried to access or modify a resource, we want to"},{"line_number":120,"context_line":"ensure the scope of the users token, as described in the context, matches"},{"line_number":121,"context_line":"the scope of the resource (such as a server or keypair) that is being"},{"line_number":122,"context_line":"accessed."},{"line_number":123,"context_line":""},{"line_number":124,"context_line":"In addition, there is a special case where a token has a \"global\" scope,"},{"line_number":125,"context_line":"i.e. that token has access to all resources. Some resources are considered"}],"source_content_type":"text/x-rst","patch_set":21,"id":"dfeb2761_2c0b5a7d","line":122,"in_reply_to":"dfeb2761_513785e4","updated":"2017-04-05 10:15:42.000000000","message":"The problem is I have to define a whole heap of words before it can make any sense, like \"global scope\", etc. Been struggling to find a way around that.","commit_id":"2ce720bb89fd042e118c62532e2440e1a7369a5a"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"b8d1ab62ce7fbc17e3881dcc016c1a9d6424b1bc","unresolved":false,"context_lines":[{"line_number":121,"context_line":"the scope of the resource (such as a server or keypair) that is being"},{"line_number":122,"context_line":"accessed."},{"line_number":123,"context_line":""},{"line_number":124,"context_line":"In addition, there is a special case where a token has a \"global\" scope,"},{"line_number":125,"context_line":"i.e. that token has access to all resources. Some resources are considered"},{"line_number":126,"context_line":"to have a \"global\" scope, such as hosts, where you need to have a token that"},{"line_number":127,"context_line":"has \"global\" scope to access those resources."},{"line_number":128,"context_line":""},{"line_number":129,"context_line":"Global context defined by is_admin_project"},{"line_number":130,"context_line":"------------------------------------------"}],"source_content_type":"text/x-rst","patch_set":21,"id":"9ff52f3f_df68bb22","line":127,"range":{"start_line":124,"start_character":0,"end_line":127,"end_character":45},"updated":"2017-04-12 23:39:49.000000000","message":"Doesn\u0027t this belong in the problem description section? I guess this is going to go on and explain this concept plus what it means for the proposed changes later on...that\u0027s fine.","commit_id":"2ce720bb89fd042e118c62532e2440e1a7369a5a"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"b8d1ab62ce7fbc17e3881dcc016c1a9d6424b1bc","unresolved":false,"context_lines":[{"line_number":133,"context_line":"of the project_id or user_id associated with that resource. We currently"},{"line_number":134,"context_line":"check to see if the context is \"global\" or not in both the ``admin_or_owner``"},{"line_number":135,"context_line":"rule and the database checks around project_ids:"},{"line_number":136,"context_line":"https://git.openstack.org/cgit/openstack/nova/tree/nova/db/sqlalchemy/api.py?id\u003dcec2802155a9041a80551b6a2e2fcdce0a843c2f#n323"},{"line_number":137,"context_line":""},{"line_number":138,"context_line":"Currently, we assume any context that passes ``\"is_admin\": \"role:admin\"`` (or"},{"line_number":139,"context_line":"whatever the policy file says) is a global context."}],"source_content_type":"text/x-rst","patch_set":21,"id":"9ff52f3f_824c1c77","line":136,"updated":"2017-04-12 23:39:49.000000000","message":"To check my understanding, it\u0027s because:\n\nif nova.context.is_user_context(context) and project_only:\n\nWill evaluate to False because is_user_context will be False if the token is for an admin because of role:admin?","commit_id":"2ce720bb89fd042e118c62532e2440e1a7369a5a"},{"author":{"_account_id":782,"name":"John Garbutt","email":"john@johngarbutt.com","username":"johngarbutt"},"change_message_id":"9807058d37e1f71d5136b9ae91ef210141ab4538","unresolved":false,"context_lines":[{"line_number":133,"context_line":"of the project_id or user_id associated with that resource. We currently"},{"line_number":134,"context_line":"check to see if the context is \"global\" or not in both the ``admin_or_owner``"},{"line_number":135,"context_line":"rule and the database checks around project_ids:"},{"line_number":136,"context_line":"https://git.openstack.org/cgit/openstack/nova/tree/nova/db/sqlalchemy/api.py?id\u003dcec2802155a9041a80551b6a2e2fcdce0a843c2f#n323"},{"line_number":137,"context_line":""},{"line_number":138,"context_line":"Currently, we assume any context that passes ``\"is_admin\": \"role:admin\"`` (or"},{"line_number":139,"context_line":"whatever the policy file says) is a global context."}],"source_content_type":"text/x-rst","patch_set":21,"id":"9ff52f3f_86cbfaa3","line":136,"in_reply_to":"9ff52f3f_824c1c77","updated":"2017-04-13 14:23:54.000000000","message":"Thats correct, at least thats the logic I was thinking.","commit_id":"2ce720bb89fd042e118c62532e2440e1a7369a5a"},{"author":{"_account_id":11564,"name":"Chris Dent","email":"cdent@anticdent.org","username":"chdent"},"change_message_id":"15b9ad166dfce7532e0085e10975ae5510b0b761","unresolved":false,"context_lines":[{"line_number":141,"context_line":"This causes a problem when an operator wants to give one user in each project"},{"line_number":142,"context_line":"access to all the admin operations, like live-migration. Generally they don\u0027t"},{"line_number":143,"context_line":"want that user to have a global context that is able to live-migrate any VM in"},{"line_number":144,"context_line":"the whole cloud. This is what happens today if they have that user the admin"},{"line_number":145,"context_line":"role."},{"line_number":146,"context_line":""},{"line_number":147,"context_line":"Keystone has introduced the concept of ``is_admin_project``. When that is"}],"source_content_type":"text/x-rst","patch_set":21,"id":"dfeb2761_71416939","line":144,"updated":"2017-04-04 11:25:44.000000000","message":"s/have/give/","commit_id":"2ce720bb89fd042e118c62532e2440e1a7369a5a"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"b8d1ab62ce7fbc17e3881dcc016c1a9d6424b1bc","unresolved":false,"context_lines":[{"line_number":144,"context_line":"the whole cloud. This is what happens today if they have that user the admin"},{"line_number":145,"context_line":"role."},{"line_number":146,"context_line":""},{"line_number":147,"context_line":"Keystone has introduced the concept of ``is_admin_project``. When that is"},{"line_number":148,"context_line":"``True`` it means the context.project_id is the \"special\" admin project."},{"line_number":149,"context_line":"The idea behind that feature is when you have a token for that special"},{"line_number":150,"context_line":"project, the roles you have in that project apply \"globally\". Its possible"}],"source_content_type":"text/x-rst","patch_set":21,"id":"9ff52f3f_c2490461","line":147,"range":{"start_line":147,"start_character":41,"end_line":147,"end_character":57},"updated":"2017-04-12 23:39:49.000000000","message":"Where is this defined? Lance pointed me to this:\n\nhttps://github.com/openstack/keystone/blob/4767e58effff12290d5b01ad20b06578eab71318/keystone/conf/resource.py#L59-L69\n\nThis might be a helpful example:\n\n(5:06:43 PM) lbragstad: if you have the \u0027admin\u0027 role on the super-special is_admin project you get god-mode\n(5:06:53 PM) lbragstad: which makes you admin across the deployment\n(5:07:10 PM) lbragstad: it\u0027s essentially a workaround for\n(5:07:15 PM) mriedem: yeah what johnthetubaguy refers to global context in https://review.openstack.org/#/c/433037/21/specs/pike/approved/policy-remove-scope-checks.rst@129\n(5:07:16 PM) lbragstad: is_admin everywhere\n(5:07:49 PM) lbragstad: mriedem yes - exactly\n(5:07:52 PM) mriedem: so i want global god admin for my hosting admin, and project admin for my hosted tenant people in a hybrid cloud thingy\n(5:08:01 PM) lbragstad: mriedem right\n(5:08:06 PM) mriedem: e.g. the ibm guy at bluebox is god admin and the admin at acme is the project admin\n(5:08:09 PM) mriedem: ok cool\n(5:08:15 PM) lbragstad: yep","commit_id":"2ce720bb89fd042e118c62532e2440e1a7369a5a"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"b8d1ab62ce7fbc17e3881dcc016c1a9d6424b1bc","unresolved":false,"context_lines":[{"line_number":145,"context_line":"role."},{"line_number":146,"context_line":""},{"line_number":147,"context_line":"Keystone has introduced the concept of ``is_admin_project``. When that is"},{"line_number":148,"context_line":"``True`` it means the context.project_id is the \"special\" admin project."},{"line_number":149,"context_line":"The idea behind that feature is when you have a token for that special"},{"line_number":150,"context_line":"project, the roles you have in that project apply \"globally\". Its possible"},{"line_number":151,"context_line":"those roles don\u0027t allow access to anything in Nova, but the token should"}],"source_content_type":"text/x-rst","patch_set":21,"id":"9ff52f3f_82d1bc5a","line":148,"range":{"start_line":148,"start_character":49,"end_line":148,"end_character":56},"updated":"2017-04-12 23:39:49.000000000","message":"This is the god-mode one? I thought that was is_admin, and is_admin_project is admin on the project, but not the entire deployment?","commit_id":"2ce720bb89fd042e118c62532e2440e1a7369a5a"},{"author":{"_account_id":782,"name":"John Garbutt","email":"john@johngarbutt.com","username":"johngarbutt"},"change_message_id":"9807058d37e1f71d5136b9ae91ef210141ab4538","unresolved":false,"context_lines":[{"line_number":145,"context_line":"role."},{"line_number":146,"context_line":""},{"line_number":147,"context_line":"Keystone has introduced the concept of ``is_admin_project``. When that is"},{"line_number":148,"context_line":"``True`` it means the context.project_id is the \"special\" admin project."},{"line_number":149,"context_line":"The idea behind that feature is when you have a token for that special"},{"line_number":150,"context_line":"project, the roles you have in that project apply \"globally\". Its possible"},{"line_number":151,"context_line":"those roles don\u0027t allow access to anything in Nova, but the token should"}],"source_content_type":"text/x-rst","patch_set":21,"id":"9ff52f3f_4673b281","line":148,"range":{"start_line":148,"start_character":49,"end_line":148,"end_character":56},"in_reply_to":"9ff52f3f_82d1bc5a","updated":"2017-04-13 14:23:54.000000000","message":"\"special\" admin project is how you get the god-mode.","commit_id":"2ce720bb89fd042e118c62532e2440e1a7369a5a"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"b8d1ab62ce7fbc17e3881dcc016c1a9d6424b1bc","unresolved":false,"context_lines":[{"line_number":156,"context_line":"check if ``instance.project_id`` matches ``context.project_id`` or not."},{"line_number":157,"context_line":"This means if you get the admin role, you no longer automatically get access"},{"line_number":158,"context_line":"to all resources in the system, you only get the admin role applying to"},{"line_number":159,"context_line":"resources that match ``context.project_id``. If an operator assigns a user"},{"line_number":160,"context_line":"with a role in the special admin project that gives them read access in Nova,"},{"line_number":161,"context_line":"that read access should apply across the whole of Nova. All checks for project"},{"line_number":162,"context_line":"membership to allow access should be skipped."},{"line_number":163,"context_line":""},{"line_number":164,"context_line":"Now we have introduced this concept, we look at how this concept can be used"},{"line_number":165,"context_line":"when we add explicit scope checks into the API code."}],"source_content_type":"text/x-rst","patch_set":21,"id":"9ff52f3f_a21720ee","line":162,"range":{"start_line":159,"start_character":45,"end_line":162,"end_character":45},"updated":"2017-04-12 23:39:49.000000000","message":"This is a bit confusing, but I think it just means, if an operator Jim (with god-mode) grants god-mode access to Bob, then we shouldn\u0027t check project membership for Bob, because Bob has god-mode privileges.\n\nIf Jim grants project-admin to Larry in project \"accounting\", then we will check access for Larry within the project that he is admin on, but he doesn\u0027t have admin access to project \"human resources\".","commit_id":"2ce720bb89fd042e118c62532e2440e1a7369a5a"},{"author":{"_account_id":782,"name":"John Garbutt","email":"john@johngarbutt.com","username":"johngarbutt"},"change_message_id":"9807058d37e1f71d5136b9ae91ef210141ab4538","unresolved":false,"context_lines":[{"line_number":156,"context_line":"check if ``instance.project_id`` matches ``context.project_id`` or not."},{"line_number":157,"context_line":"This means if you get the admin role, you no longer automatically get access"},{"line_number":158,"context_line":"to all resources in the system, you only get the admin role applying to"},{"line_number":159,"context_line":"resources that match ``context.project_id``. If an operator assigns a user"},{"line_number":160,"context_line":"with a role in the special admin project that gives them read access in Nova,"},{"line_number":161,"context_line":"that read access should apply across the whole of Nova. All checks for project"},{"line_number":162,"context_line":"membership to allow access should be skipped."},{"line_number":163,"context_line":""},{"line_number":164,"context_line":"Now we have introduced this concept, we look at how this concept can be used"},{"line_number":165,"context_line":"when we add explicit scope checks into the API code."}],"source_content_type":"text/x-rst","patch_set":21,"id":"9ff52f3f_06f00ac9","line":162,"range":{"start_line":159,"start_character":45,"end_line":162,"end_character":45},"in_reply_to":"9ff52f3f_a21720ee","updated":"2017-04-13 14:23:54.000000000","message":"Yeah, that sounds correct.","commit_id":"2ce720bb89fd042e118c62532e2440e1a7369a5a"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"b8d1ab62ce7fbc17e3881dcc016c1a9d6424b1bc","unresolved":false,"context_lines":[{"line_number":169,"context_line":""},{"line_number":170,"context_line":"Scope checking is where we compare the scope of the API resource being"},{"line_number":171,"context_line":"accessed (such as server.project_id, keypair.user_id) to the scope of the"},{"line_number":172,"context_line":"token as defined in the user context object. Logically we are doing checks"},{"line_number":173,"context_line":"very similar to these:"},{"line_number":174,"context_line":""},{"line_number":175,"context_line":"* ``server.project_id \u003d\u003d context.project_id or context.is_global``"}],"source_content_type":"text/x-rst","patch_set":21,"id":"9ff52f3f_c2c8e475","line":172,"range":{"start_line":172,"start_character":24,"end_line":172,"end_character":28},"updated":"2017-04-12 23:39:49.000000000","message":"s/user/request/?","commit_id":"2ce720bb89fd042e118c62532e2440e1a7369a5a"},{"author":{"_account_id":782,"name":"John Garbutt","email":"john@johngarbutt.com","username":"johngarbutt"},"change_message_id":"9807058d37e1f71d5136b9ae91ef210141ab4538","unresolved":false,"context_lines":[{"line_number":169,"context_line":""},{"line_number":170,"context_line":"Scope checking is where we compare the scope of the API resource being"},{"line_number":171,"context_line":"accessed (such as server.project_id, keypair.user_id) to the scope of the"},{"line_number":172,"context_line":"token as defined in the user context object. Logically we are doing checks"},{"line_number":173,"context_line":"very similar to these:"},{"line_number":174,"context_line":""},{"line_number":175,"context_line":"* ``server.project_id \u003d\u003d context.project_id or context.is_global``"}],"source_content_type":"text/x-rst","patch_set":21,"id":"9ff52f3f_86aada82","line":172,"range":{"start_line":172,"start_character":24,"end_line":172,"end_character":28},"in_reply_to":"9ff52f3f_c2c8e475","updated":"2017-04-13 14:23:54.000000000","message":"I think I mean \"user\u0027s request context\" technically, I should be more careful with the wording there I guess.","commit_id":"2ce720bb89fd042e118c62532e2440e1a7369a5a"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"b8d1ab62ce7fbc17e3881dcc016c1a9d6424b1bc","unresolved":false,"context_lines":[{"line_number":177,"context_line":""},{"line_number":178,"context_line":"Note: above we defined how we check if the context is global or not."},{"line_number":179,"context_line":"For backwards compatibility, we should continue to allow the role ``admin``"},{"line_number":180,"context_line":"give access to all resources (the \"global\" scope). More on this later."},{"line_number":181,"context_line":""},{"line_number":182,"context_line":"As previously discussed, scope checks currently happen both in the"},{"line_number":183,"context_line":"database layer and as part of some policy rule checks. To make it much easier"}],"source_content_type":"text/x-rst","patch_set":21,"id":"9ff52f3f_42985469","line":180,"range":{"start_line":180,"start_character":0,"end_line":180,"end_character":4},"updated":"2017-04-12 23:39:49.000000000","message":"be given?","commit_id":"2ce720bb89fd042e118c62532e2440e1a7369a5a"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"b8d1ab62ce7fbc17e3881dcc016c1a9d6424b1bc","unresolved":false,"context_lines":[{"line_number":187,"context_line":""},{"line_number":188,"context_line":"To remove the database layer check, we can take these steps:"},{"line_number":189,"context_line":""},{"line_number":190,"context_line":"* In the API use context.elevated() for all DB calls to bypass the project"},{"line_number":191,"context_line":"  checks in the database logic."},{"line_number":192,"context_line":"* Once we have all APIs protected by the explicit scope check, we can consider"},{"line_number":193,"context_line":"  dropping all the scope checks in the database."}],"source_content_type":"text/x-rst","patch_set":21,"id":"9ff52f3f_c27584fc","line":190,"updated":"2017-04-12 23:39:49.000000000","message":"So going back to the trove service user example from earlier, this fixes that because even though project_only\u003dTrue is passed in, the context.is_user_context call will return False and we won\u0027t filter on project_id. Then rather than raise InstanceNotFound from the database, we\u0027ll get the instance back and can actually check the policy against the context and API resource. I think I understand that now - maybe add that to the explanation here to tie things back to the problem description?\n\nHowever, going back to listing instances in the DB API:\n\nhttps://git.openstack.org/cgit/openstack/nova/tree/nova/db/sqlalchemy/api.py?id\u003dcec2802155a9041a80551b6a2e2fcdce0a843c2f#n2031\n\nThat\u0027s different, and if the context is elevated it\u0027s going to return all instances and not filter on project, which is not what we want. How do we resolve that?","commit_id":"2ce720bb89fd042e118c62532e2440e1a7369a5a"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"cecaed6baeefc7b2f545f8f4cf75a2c9244c6ad4","unresolved":false,"context_lines":[{"line_number":187,"context_line":""},{"line_number":188,"context_line":"To remove the database layer check, we can take these steps:"},{"line_number":189,"context_line":""},{"line_number":190,"context_line":"* In the API use context.elevated() for all DB calls to bypass the project"},{"line_number":191,"context_line":"  checks in the database logic."},{"line_number":192,"context_line":"* Once we have all APIs protected by the explicit scope check, we can consider"},{"line_number":193,"context_line":"  dropping all the scope checks in the database."}],"source_content_type":"text/x-rst","patch_set":21,"id":"9ff52f3f_bd3a88e4","line":190,"in_reply_to":"9ff52f3f_46d052f8","updated":"2017-04-13 14:48:20.000000000","message":"How is this filtered by project for an admin?\n\nhttps://git.openstack.org/cgit/openstack/nova/tree/nova/db/sqlalchemy/api.py?id\u003dcec2802155a9041a80551b6a2e2fcdce0a843c2f#n2031","commit_id":"2ce720bb89fd042e118c62532e2440e1a7369a5a"},{"author":{"_account_id":782,"name":"John Garbutt","email":"john@johngarbutt.com","username":"johngarbutt"},"change_message_id":"9807058d37e1f71d5136b9ae91ef210141ab4538","unresolved":false,"context_lines":[{"line_number":187,"context_line":""},{"line_number":188,"context_line":"To remove the database layer check, we can take these steps:"},{"line_number":189,"context_line":""},{"line_number":190,"context_line":"* In the API use context.elevated() for all DB calls to bypass the project"},{"line_number":191,"context_line":"  checks in the database logic."},{"line_number":192,"context_line":"* Once we have all APIs protected by the explicit scope check, we can consider"},{"line_number":193,"context_line":"  dropping all the scope checks in the database."}],"source_content_type":"text/x-rst","patch_set":21,"id":"9ff52f3f_46d052f8","line":190,"in_reply_to":"9ff52f3f_c27584fc","updated":"2017-04-13 14:23:54.000000000","message":"List instances, by default is always filtered by project_id, its only all_tenants\u003dTrue that means list everything.\n\nSo the question there is are you allowed to list the instances for the requested project_id, of if you do all_tenants, do you have global context?","commit_id":"2ce720bb89fd042e118c62532e2440e1a7369a5a"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"b8d1ab62ce7fbc17e3881dcc016c1a9d6424b1bc","unresolved":false,"context_lines":[{"line_number":189,"context_line":""},{"line_number":190,"context_line":"* In the API use context.elevated() for all DB calls to bypass the project"},{"line_number":191,"context_line":"  checks in the database logic."},{"line_number":192,"context_line":"* Once we have all APIs protected by the explicit scope check, we can consider"},{"line_number":193,"context_line":"  dropping all the scope checks in the database."},{"line_number":194,"context_line":""},{"line_number":195,"context_line":"To remove the policy layer checks:"}],"source_content_type":"text/x-rst","patch_set":21,"id":"9ff52f3f_0255ac50","line":192,"updated":"2017-04-12 23:39:49.000000000","message":"How do we know if we\u0027re missing some explicit scope checks?","commit_id":"2ce720bb89fd042e118c62532e2440e1a7369a5a"},{"author":{"_account_id":782,"name":"John Garbutt","email":"john@johngarbutt.com","username":"johngarbutt"},"change_message_id":"9807058d37e1f71d5136b9ae91ef210141ab4538","unresolved":false,"context_lines":[{"line_number":189,"context_line":""},{"line_number":190,"context_line":"* In the API use context.elevated() for all DB calls to bypass the project"},{"line_number":191,"context_line":"  checks in the database logic."},{"line_number":192,"context_line":"* Once we have all APIs protected by the explicit scope check, we can consider"},{"line_number":193,"context_line":"  dropping all the scope checks in the database."},{"line_number":194,"context_line":""},{"line_number":195,"context_line":"To remove the policy layer checks:"}],"source_content_type":"text/x-rst","patch_set":21,"id":"9ff52f3f_46f9727e","line":192,"in_reply_to":"9ff52f3f_0255ac50","updated":"2017-04-13 14:23:54.000000000","message":"By adding the proposed functional tests.","commit_id":"2ce720bb89fd042e118c62532e2440e1a7369a5a"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"b8d1ab62ce7fbc17e3881dcc016c1a9d6424b1bc","unresolved":false,"context_lines":[{"line_number":192,"context_line":"* Once we have all APIs protected by the explicit scope check, we can consider"},{"line_number":193,"context_line":"  dropping all the scope checks in the database."},{"line_number":194,"context_line":""},{"line_number":195,"context_line":"To remove the policy layer checks:"},{"line_number":196,"context_line":""},{"line_number":197,"context_line":"* Once all scope checks are in place, ``admin_or_owner`` is defaulted to ``@``"},{"line_number":198,"context_line":"  which means anyone can access that API."},{"line_number":199,"context_line":"* Note: we keep ``admin_or_owner`` for one cycle to allow for a smooth"},{"line_number":200,"context_line":"  upgrade experience. After which time we can rename the rule to something"},{"line_number":201,"context_line":"  more appropriate."},{"line_number":202,"context_line":"* Longer term we can remove the target passed into any policy checks, so"},{"line_number":203,"context_line":"  there can be no scope checks done in the policy file. But to allow a"},{"line_number":204,"context_line":"  smooth upgrade, we only remove the scope checks done in the default"},{"line_number":205,"context_line":"  policy rules."},{"line_number":206,"context_line":"* Note this basically leaves all the default rules in the policy file being"},{"line_number":207,"context_line":"  either ``@`` or ``role:admin``, but we will do this in a way that there is"},{"line_number":208,"context_line":"  no change to the API behaviour."},{"line_number":209,"context_line":""},{"line_number":210,"context_line":"To add the explicit scope check, we add this new policy rule::"},{"line_number":211,"context_line":""}],"source_content_type":"text/x-rst","patch_set":21,"id":"9ff52f3f_62f4785c","line":208,"range":{"start_line":195,"start_character":0,"end_line":208,"end_character":33},"updated":"2017-04-12 23:39:49.000000000","message":"I\u0027m not really following this. Can you tie in some of the earlier examples, like with the trove case or something?","commit_id":"2ce720bb89fd042e118c62532e2440e1a7369a5a"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"b8d1ab62ce7fbc17e3881dcc016c1a9d6424b1bc","unresolved":false,"context_lines":[{"line_number":209,"context_line":""},{"line_number":210,"context_line":"To add the explicit scope check, we add this new policy rule::"},{"line_number":211,"context_line":""},{"line_number":212,"context_line":"    \"context_is_global_scope\": \"is_admin_project:True\""},{"line_number":213,"context_line":""},{"line_number":214,"context_line":"The above rule will be used in this new nova context method::"},{"line_number":215,"context_line":""}],"source_content_type":"text/x-rst","patch_set":21,"id":"9ff52f3f_c2e344a4","line":212,"updated":"2017-04-12 23:39:49.000000000","message":"In talking with Lance I didn\u0027t think is_admin_project was the global scope god-mode, I thought it was admin on a project, not all projects.","commit_id":"2ce720bb89fd042e118c62532e2440e1a7369a5a"},{"author":{"_account_id":782,"name":"John Garbutt","email":"john@johngarbutt.com","username":"johngarbutt"},"change_message_id":"9807058d37e1f71d5136b9ae91ef210141ab4538","unresolved":false,"context_lines":[{"line_number":209,"context_line":""},{"line_number":210,"context_line":"To add the explicit scope check, we add this new policy rule::"},{"line_number":211,"context_line":""},{"line_number":212,"context_line":"    \"context_is_global_scope\": \"is_admin_project:True\""},{"line_number":213,"context_line":""},{"line_number":214,"context_line":"The above rule will be used in this new nova context method::"},{"line_number":215,"context_line":""}],"source_content_type":"text/x-rst","patch_set":21,"id":"9ff52f3f_e6a7664f","line":212,"in_reply_to":"9ff52f3f_c2e344a4","updated":"2017-04-13 14:23:54.000000000","message":"So thats the opposite of what I got told by adam, this is true when you want god-mode:\nhttp://specs.openstack.org/openstack/keystone-specs/specs/keystone/mitaka/is_admin_project.html\n\nAlthough I find the above spec quite confusing, I think it backs up my thinking here.","commit_id":"2ce720bb89fd042e118c62532e2440e1a7369a5a"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"b8d1ab62ce7fbc17e3881dcc016c1a9d6424b1bc","unresolved":false,"context_lines":[{"line_number":215,"context_line":""},{"line_number":216,"context_line":"    def check_scope(scope, fatal\u003dTrue)"},{"line_number":217,"context_line":""},{"line_number":218,"context_line":"It will return True, only if the target matches the current context, or the"},{"line_number":219,"context_line":"token passes the `context_is_global_scope` policy rule. It raises an exception"},{"line_number":220,"context_line":"that triggers a 403 error if fatal\u003dTrue, else if fatal\u003dFalse it returns False."},{"line_number":221,"context_line":""}],"source_content_type":"text/x-rst","patch_set":21,"id":"9ff52f3f_6267d827","line":218,"range":{"start_line":218,"start_character":33,"end_line":218,"end_character":39},"updated":"2017-04-12 23:39:49.000000000","message":"Where is the target passed in to check_scope? Is that the scope variable?","commit_id":"2ce720bb89fd042e118c62532e2440e1a7369a5a"},{"author":{"_account_id":782,"name":"John Garbutt","email":"john@johngarbutt.com","username":"johngarbutt"},"change_message_id":"9807058d37e1f71d5136b9ae91ef210141ab4538","unresolved":false,"context_lines":[{"line_number":215,"context_line":""},{"line_number":216,"context_line":"    def check_scope(scope, fatal\u003dTrue)"},{"line_number":217,"context_line":""},{"line_number":218,"context_line":"It will return True, only if the target matches the current context, or the"},{"line_number":219,"context_line":"token passes the `context_is_global_scope` policy rule. It raises an exception"},{"line_number":220,"context_line":"that triggers a 403 error if fatal\u003dTrue, else if fatal\u003dFalse it returns False."},{"line_number":221,"context_line":""}],"source_content_type":"text/x-rst","patch_set":21,"id":"9ff52f3f_e62ac68e","line":218,"range":{"start_line":218,"start_character":33,"end_line":218,"end_character":39},"in_reply_to":"9ff52f3f_6267d827","updated":"2017-04-13 14:23:54.000000000","message":"yeah, the scope parameter above.","commit_id":"2ce720bb89fd042e118c62532e2440e1a7369a5a"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"b8d1ab62ce7fbc17e3881dcc016c1a9d6424b1bc","unresolved":false,"context_lines":[{"line_number":215,"context_line":""},{"line_number":216,"context_line":"    def check_scope(scope, fatal\u003dTrue)"},{"line_number":217,"context_line":""},{"line_number":218,"context_line":"It will return True, only if the target matches the current context, or the"},{"line_number":219,"context_line":"token passes the `context_is_global_scope` policy rule. It raises an exception"},{"line_number":220,"context_line":"that triggers a 403 error if fatal\u003dTrue, else if fatal\u003dFalse it returns False."},{"line_number":221,"context_line":""},{"line_number":222,"context_line":"This will allow us to later add more complicated checks that could take into"}],"source_content_type":"text/x-rst","patch_set":21,"id":"9ff52f3f_426cd407","line":219,"range":{"start_line":218,"start_character":69,"end_line":219,"end_character":54},"updated":"2017-04-12 23:39:49.000000000","message":"Do you need to pass the context to the check_scope method?","commit_id":"2ce720bb89fd042e118c62532e2440e1a7369a5a"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"b8d1ab62ce7fbc17e3881dcc016c1a9d6424b1bc","unresolved":false,"context_lines":[{"line_number":216,"context_line":"    def check_scope(scope, fatal\u003dTrue)"},{"line_number":217,"context_line":""},{"line_number":218,"context_line":"It will return True, only if the target matches the current context, or the"},{"line_number":219,"context_line":"token passes the `context_is_global_scope` policy rule. It raises an exception"},{"line_number":220,"context_line":"that triggers a 403 error if fatal\u003dTrue, else if fatal\u003dFalse it returns False."},{"line_number":221,"context_line":""},{"line_number":222,"context_line":"This will allow us to later add more complicated checks that could take into"}],"source_content_type":"text/x-rst","patch_set":21,"id":"9ff52f3f_0276ccd9","line":219,"range":{"start_line":219,"start_character":59,"end_line":219,"end_character":65},"updated":"2017-04-12 23:39:49.000000000","message":"Raises if the check fails...","commit_id":"2ce720bb89fd042e118c62532e2440e1a7369a5a"},{"author":{"_account_id":782,"name":"John Garbutt","email":"john@johngarbutt.com","username":"johngarbutt"},"change_message_id":"9807058d37e1f71d5136b9ae91ef210141ab4538","unresolved":false,"context_lines":[{"line_number":215,"context_line":""},{"line_number":216,"context_line":"    def check_scope(scope, fatal\u003dTrue)"},{"line_number":217,"context_line":""},{"line_number":218,"context_line":"It will return True, only if the target matches the current context, or the"},{"line_number":219,"context_line":"token passes the `context_is_global_scope` policy rule. It raises an exception"},{"line_number":220,"context_line":"that triggers a 403 error if fatal\u003dTrue, else if fatal\u003dFalse it returns False."},{"line_number":221,"context_line":""},{"line_number":222,"context_line":"This will allow us to later add more complicated checks that could take into"}],"source_content_type":"text/x-rst","patch_set":21,"id":"9ff52f3f_da2c329b","line":219,"range":{"start_line":218,"start_character":69,"end_line":219,"end_character":54},"in_reply_to":"9ff52f3f_426cd407","updated":"2017-04-13 14:23:54.000000000","message":"Its a method on the context, like the policy check.","commit_id":"2ce720bb89fd042e118c62532e2440e1a7369a5a"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"b8d1ab62ce7fbc17e3881dcc016c1a9d6424b1bc","unresolved":false,"context_lines":[{"line_number":222,"context_line":"This will allow us to later add more complicated checks that could take into"},{"line_number":223,"context_line":"account hierarchical multi-tenancy and/or domain scoped tokens."},{"line_number":224,"context_line":""},{"line_number":225,"context_line":"To show a keypair, we will pass ``scope\u003d{\"user_id\": keypair.user_id}``,"},{"line_number":226,"context_line":"for a show server we would pass ``scope\u003d{\"project_id\": instance.project_id}``,"},{"line_number":227,"context_line":"for a list of all servers across all project we would pass ``scope\u003d{}``,"},{"line_number":228,"context_line":"i.e. to represent \"global\" scope, we use the empty scope. If you consider"}],"source_content_type":"text/x-rst","patch_set":21,"id":"9ff52f3f_c22d84a9","line":225,"range":{"start_line":225,"start_character":32,"end_line":225,"end_character":70},"updated":"2017-04-12 23:39:49.000000000","message":"So the default policy rule for showing keypairs is:\n\n\"os_compute_api:os-keypairs:show\": \"rule:admin_api or user_id:%(user_id)s\"\n\nIf we start hard-coding things in the code now, then you can\u0027t do anything with the policy file to change this right? Like what if I want to restrict showing keypairs to just the project level and not the user level? The example maybe doesn\u0027t make sense, but I\u0027m wondering about the implications of hard-coding the rules in code, since I thought operators also used the policy file to disable certain APIs that their cloud won\u0027t support. The recent discussion around support for extending the size of attached volumes comes to mind - xen clouds won\u0027t support that right away, so I\u0027d think operators would want to disable that globally with policy.","commit_id":"2ce720bb89fd042e118c62532e2440e1a7369a5a"},{"author":{"_account_id":782,"name":"John Garbutt","email":"john@johngarbutt.com","username":"johngarbutt"},"change_message_id":"9807058d37e1f71d5136b9ae91ef210141ab4538","unresolved":false,"context_lines":[{"line_number":222,"context_line":"This will allow us to later add more complicated checks that could take into"},{"line_number":223,"context_line":"account hierarchical multi-tenancy and/or domain scoped tokens."},{"line_number":224,"context_line":""},{"line_number":225,"context_line":"To show a keypair, we will pass ``scope\u003d{\"user_id\": keypair.user_id}``,"},{"line_number":226,"context_line":"for a show server we would pass ``scope\u003d{\"project_id\": instance.project_id}``,"},{"line_number":227,"context_line":"for a list of all servers across all project we would pass ``scope\u003d{}``,"},{"line_number":228,"context_line":"i.e. to represent \"global\" scope, we use the empty scope. If you consider"}],"source_content_type":"text/x-rst","patch_set":21,"id":"9ff52f3f_7a408636","line":225,"range":{"start_line":225,"start_character":32,"end_line":225,"end_character":70},"in_reply_to":"9ff52f3f_c22d84a9","updated":"2017-04-13 14:23:54.000000000","message":"Right, you can\u0027t change the scope any more (well you can\u0027t really change it today either), but you can still stop people using the API.\n\nFor me the implication is stopping this sort of \"confusion\" that was around this spec:\nhttp://specs.openstack.org/openstack/nova-specs/specs/newton/implemented/user-id-based-policy-enforcement.html\n\nIt also generally stops lots of iterop strangeness too.","commit_id":"2ce720bb89fd042e118c62532e2440e1a7369a5a"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"b8d1ab62ce7fbc17e3881dcc016c1a9d6424b1bc","unresolved":false,"context_lines":[{"line_number":224,"context_line":""},{"line_number":225,"context_line":"To show a keypair, we will pass ``scope\u003d{\"user_id\": keypair.user_id}``,"},{"line_number":226,"context_line":"for a show server we would pass ``scope\u003d{\"project_id\": instance.project_id}``,"},{"line_number":227,"context_line":"for a list of all servers across all project we would pass ``scope\u003d{}``,"},{"line_number":228,"context_line":"i.e. to represent \"global\" scope, we use the empty scope. If you consider"},{"line_number":229,"context_line":"listing all global flavors in the system, any token scope is allowed to do"},{"line_number":230,"context_line":"that, so no scope check is performed. But if you modify a global flavor,"}],"source_content_type":"text/x-rst","patch_set":21,"id":"9ff52f3f_4213b467","line":227,"range":{"start_line":227,"start_character":0,"end_line":227,"end_character":71},"updated":"2017-04-12 23:39:49.000000000","message":"But don\u0027t we want to just list servers for context.project_id? Or are you thinking of \"os_compute_api:servers:index:get_all_tenants\"?","commit_id":"2ce720bb89fd042e118c62532e2440e1a7369a5a"},{"author":{"_account_id":782,"name":"John Garbutt","email":"john@johngarbutt.com","username":"johngarbutt"},"change_message_id":"9807058d37e1f71d5136b9ae91ef210141ab4538","unresolved":false,"context_lines":[{"line_number":224,"context_line":""},{"line_number":225,"context_line":"To show a keypair, we will pass ``scope\u003d{\"user_id\": keypair.user_id}``,"},{"line_number":226,"context_line":"for a show server we would pass ``scope\u003d{\"project_id\": instance.project_id}``,"},{"line_number":227,"context_line":"for a list of all servers across all project we would pass ``scope\u003d{}``,"},{"line_number":228,"context_line":"i.e. to represent \"global\" scope, we use the empty scope. If you consider"},{"line_number":229,"context_line":"listing all global flavors in the system, any token scope is allowed to do"},{"line_number":230,"context_line":"that, so no scope check is performed. But if you modify a global flavor,"}],"source_content_type":"text/x-rst","patch_set":21,"id":"9ff52f3f_dac0b253","line":227,"range":{"start_line":227,"start_character":0,"end_line":227,"end_character":71},"in_reply_to":"9ff52f3f_4213b467","updated":"2017-04-13 14:23:54.000000000","message":"yeah, that right, it kinda replaces that policy check.","commit_id":"2ce720bb89fd042e118c62532e2440e1a7369a5a"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"b8d1ab62ce7fbc17e3881dcc016c1a9d6424b1bc","unresolved":false,"context_lines":[{"line_number":252,"context_line":""},{"line_number":253,"context_line":"* POST /servers"},{"line_number":254,"context_line":""},{"line_number":255,"context_line":"  * no scope check, anyone with the correct role can do this"},{"line_number":256,"context_line":"  * rule:admin_or_owner"},{"line_number":257,"context_line":""},{"line_number":258,"context_line":"* POST /servers/\u003cid\u003e/action {\"os-migrateLive\": {...}}"}],"source_content_type":"text/x-rst","patch_set":21,"id":"9ff52f3f_25267ab9","line":255,"updated":"2017-04-12 23:39:49.000000000","message":"So {}?","commit_id":"2ce720bb89fd042e118c62532e2440e1a7369a5a"},{"author":{"_account_id":782,"name":"John Garbutt","email":"john@johngarbutt.com","username":"johngarbutt"},"change_message_id":"9807058d37e1f71d5136b9ae91ef210141ab4538","unresolved":false,"context_lines":[{"line_number":252,"context_line":""},{"line_number":253,"context_line":"* POST /servers"},{"line_number":254,"context_line":""},{"line_number":255,"context_line":"  * no scope check, anyone with the correct role can do this"},{"line_number":256,"context_line":"  * rule:admin_or_owner"},{"line_number":257,"context_line":""},{"line_number":258,"context_line":"* POST /servers/\u003cid\u003e/action {\"os-migrateLive\": {...}}"}],"source_content_type":"text/x-rst","patch_set":21,"id":"9ff52f3f_5acca288","line":255,"in_reply_to":"9ff52f3f_25267ab9","updated":"2017-04-13 14:23:54.000000000","message":"No, that would be check for global scope, here we just don\u0027t call the method.","commit_id":"2ce720bb89fd042e118c62532e2440e1a7369a5a"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"b8d1ab62ce7fbc17e3881dcc016c1a9d6424b1bc","unresolved":false,"context_lines":[{"line_number":262,"context_line":""},{"line_number":263,"context_line":"* GET /flavors"},{"line_number":264,"context_line":""},{"line_number":265,"context_line":"  * no scope check, as every authorized users can list flavors"},{"line_number":266,"context_line":"  * rule:admin_or_owner"},{"line_number":267,"context_line":"  * (The above rule makes little sense, but we keep it to aid upgrades)"},{"line_number":268,"context_line":""}],"source_content_type":"text/x-rst","patch_set":21,"id":"9ff52f3f_e53772e3","line":265,"updated":"2017-04-12 23:39:49.000000000","message":"{}","commit_id":"2ce720bb89fd042e118c62532e2440e1a7369a5a"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"b8d1ab62ce7fbc17e3881dcc016c1a9d6424b1bc","unresolved":false,"context_lines":[{"line_number":264,"context_line":""},{"line_number":265,"context_line":"  * no scope check, as every authorized users can list flavors"},{"line_number":266,"context_line":"  * rule:admin_or_owner"},{"line_number":267,"context_line":"  * (The above rule makes little sense, but we keep it to aid upgrades)"},{"line_number":268,"context_line":""},{"line_number":269,"context_line":"* POST /flavors"},{"line_number":270,"context_line":""}],"source_content_type":"text/x-rst","patch_set":21,"id":"9ff52f3f_255b1a2f","line":267,"range":{"start_line":267,"start_character":4,"end_line":267,"end_character":71},"updated":"2017-04-12 23:39:49.000000000","message":"Above you say:\n\nNote: we keep ``admin_or_owner`` for one cycle to allow for a smooth\n  upgrade experience. After which time we can rename the rule to something\n  more appropriate.\n\n--\n\nBut how do you deprecate these things such that in Queens you can drop that rule? How is it any less troublesome in Queens?","commit_id":"2ce720bb89fd042e118c62532e2440e1a7369a5a"},{"author":{"_account_id":782,"name":"John Garbutt","email":"john@johngarbutt.com","username":"johngarbutt"},"change_message_id":"9807058d37e1f71d5136b9ae91ef210141ab4538","unresolved":false,"context_lines":[{"line_number":264,"context_line":""},{"line_number":265,"context_line":"  * no scope check, as every authorized users can list flavors"},{"line_number":266,"context_line":"  * rule:admin_or_owner"},{"line_number":267,"context_line":"  * (The above rule makes little sense, but we keep it to aid upgrades)"},{"line_number":268,"context_line":""},{"line_number":269,"context_line":"* POST /flavors"},{"line_number":270,"context_line":""}],"source_content_type":"text/x-rst","patch_set":21,"id":"9ff52f3f_3a779e3d","line":267,"range":{"start_line":267,"start_character":4,"end_line":267,"end_character":71},"in_reply_to":"9ff52f3f_255b1a2f","updated":"2017-04-13 14:23:54.000000000","message":"So thats actually handled better in the follow on spec, with some deprecation warnings. I should probably pull that stuff into here, but that means more complexity :(","commit_id":"2ce720bb89fd042e118c62532e2440e1a7369a5a"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"b8d1ab62ce7fbc17e3881dcc016c1a9d6424b1bc","unresolved":false,"context_lines":[{"line_number":268,"context_line":""},{"line_number":269,"context_line":"* POST /flavors"},{"line_number":270,"context_line":""},{"line_number":271,"context_line":"  * scope check: {} (i.e. global, unless is a project specific flavor)"},{"line_number":272,"context_line":"  * rule:admin_api"},{"line_number":273,"context_line":"  * Note: this means you have to have the admin rule in the special admin"},{"line_number":274,"context_line":"    project to get access to add global flavors."}],"source_content_type":"text/x-rst","patch_set":21,"id":"9ff52f3f_455bbe86","line":271,"range":{"start_line":271,"start_character":34,"end_line":271,"end_character":69},"updated":"2017-04-12 23:39:49.000000000","message":"How do we tell? I assume this is related to os_compute_api:os-flavor-access?","commit_id":"2ce720bb89fd042e118c62532e2440e1a7369a5a"},{"author":{"_account_id":782,"name":"John Garbutt","email":"john@johngarbutt.com","username":"johngarbutt"},"change_message_id":"9807058d37e1f71d5136b9ae91ef210141ab4538","unresolved":false,"context_lines":[{"line_number":268,"context_line":""},{"line_number":269,"context_line":"* POST /flavors"},{"line_number":270,"context_line":""},{"line_number":271,"context_line":"  * scope check: {} (i.e. global, unless is a project specific flavor)"},{"line_number":272,"context_line":"  * rule:admin_api"},{"line_number":273,"context_line":"  * Note: this means you have to have the admin rule in the special admin"},{"line_number":274,"context_line":"    project to get access to add global flavors."}],"source_content_type":"text/x-rst","patch_set":21,"id":"9ff52f3f_3ae43eac","line":271,"range":{"start_line":271,"start_character":34,"end_line":271,"end_character":69},"in_reply_to":"9ff52f3f_455bbe86","updated":"2017-04-13 14:23:54.000000000","message":"yeah, honestly, I am sketchy on those details now.","commit_id":"2ce720bb89fd042e118c62532e2440e1a7369a5a"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"b8d1ab62ce7fbc17e3881dcc016c1a9d6424b1bc","unresolved":false,"context_lines":[{"line_number":280,"context_line":"Alternatives"},{"line_number":281,"context_line":"------------"},{"line_number":282,"context_line":""},{"line_number":283,"context_line":"We could look at passing a valid target into all of the policy checks."},{"line_number":284,"context_line":"However this means deployers can easily change the API in fundamental ways"},{"line_number":285,"context_line":"that affect the security model. That hurts interoperability and can lead to"},{"line_number":286,"context_line":"obscure security issues. It is also makes for a much simpler policy file"}],"source_content_type":"text/x-rst","patch_set":21,"id":"9ff52f3f_254afa7f","line":283,"updated":"2017-04-12 23:39:49.000000000","message":"Does this mean we can\u0027t just fix the trove service user / model_query scenario now without also dealing with completely redoing all of the scope checking stuff in the API? I think I understand the problem and the fix more or less for the DB API issue, but I get a bit lost with \"remove policy layer checks\" parts and the new check_scope method. Are those tightly coupled? Or are they conflated here for convenience? If they are not tied together, it almost seems like we should have separate specs.","commit_id":"2ce720bb89fd042e118c62532e2440e1a7369a5a"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"b8d1ab62ce7fbc17e3881dcc016c1a9d6424b1bc","unresolved":false,"context_lines":[{"line_number":283,"context_line":"We could look at passing a valid target into all of the policy checks."},{"line_number":284,"context_line":"However this means deployers can easily change the API in fundamental ways"},{"line_number":285,"context_line":"that affect the security model. That hurts interoperability and can lead to"},{"line_number":286,"context_line":"obscure security issues. It is also makes for a much simpler policy file"},{"line_number":287,"context_line":"when there is no need to consider the scope of operations in the policy file."},{"line_number":288,"context_line":""},{"line_number":289,"context_line":"Its possible patrole gives reasonable RBAC coverage, but good functional tests"}],"source_content_type":"text/x-rst","patch_set":21,"id":"9ff52f3f_45d05eca","line":286,"range":{"start_line":286,"start_character":25,"end_line":286,"end_character":41},"updated":"2017-04-12 23:39:49.000000000","message":"It also makes","commit_id":"2ce720bb89fd042e118c62532e2440e1a7369a5a"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"b8d1ab62ce7fbc17e3881dcc016c1a9d6424b1bc","unresolved":false,"context_lines":[{"line_number":286,"context_line":"obscure security issues. It is also makes for a much simpler policy file"},{"line_number":287,"context_line":"when there is no need to consider the scope of operations in the policy file."},{"line_number":288,"context_line":""},{"line_number":289,"context_line":"Its possible patrole gives reasonable RBAC coverage, but good functional tests"},{"line_number":290,"context_line":"in tree will help with all the work on related specs, such as those looking to"},{"line_number":291,"context_line":"add a distinction between read, write, and administrator APIs."},{"line_number":292,"context_line":""},{"line_number":293,"context_line":"Data model impact"},{"line_number":294,"context_line":"-----------------"}],"source_content_type":"text/x-rst","patch_set":21,"id":"9ff52f3f_c5e34ea4","line":291,"range":{"start_line":289,"start_character":0,"end_line":291,"end_character":62},"updated":"2017-04-12 23:39:49.000000000","message":"This seems premature to note in alternatives given you haven\u0027t discussed testing any of this yet. Just an observation.","commit_id":"2ce720bb89fd042e118c62532e2440e1a7369a5a"},{"author":{"_account_id":782,"name":"John Garbutt","email":"john@johngarbutt.com","username":"johngarbutt"},"change_message_id":"9807058d37e1f71d5136b9ae91ef210141ab4538","unresolved":false,"context_lines":[{"line_number":286,"context_line":"obscure security issues. It is also makes for a much simpler policy file"},{"line_number":287,"context_line":"when there is no need to consider the scope of operations in the policy file."},{"line_number":288,"context_line":""},{"line_number":289,"context_line":"Its possible patrole gives reasonable RBAC coverage, but good functional tests"},{"line_number":290,"context_line":"in tree will help with all the work on related specs, such as those looking to"},{"line_number":291,"context_line":"add a distinction between read, write, and administrator APIs."},{"line_number":292,"context_line":""},{"line_number":293,"context_line":"Data model impact"},{"line_number":294,"context_line":"-----------------"}],"source_content_type":"text/x-rst","patch_set":21,"id":"9ff52f3f_7a5f6641","line":291,"range":{"start_line":289,"start_character":0,"end_line":291,"end_character":62},"in_reply_to":"9ff52f3f_c5e34ea4","updated":"2017-04-13 14:23:54.000000000","message":"Oh, that must have got dropped above, oops.","commit_id":"2ce720bb89fd042e118c62532e2440e1a7369a5a"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"b8d1ab62ce7fbc17e3881dcc016c1a9d6424b1bc","unresolved":false,"context_lines":[{"line_number":362,"context_line":"Testing"},{"line_number":363,"context_line":"\u003d\u003d\u003d\u003d\u003d\u003d\u003d"},{"line_number":364,"context_line":""},{"line_number":365,"context_line":"None"},{"line_number":366,"context_line":""},{"line_number":367,"context_line":"Documentation Impact"},{"line_number":368,"context_line":"\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d"}],"source_content_type":"text/x-rst","patch_set":21,"id":"9ff52f3f_8530a609","line":365,"updated":"2017-04-12 23:39:49.000000000","message":"Huh? I\u0027m pretty sure that in earlier revisions of this, building up functional tests to assert all of this stuff was a pretty major part of the change so we knew if we were regressing anything when we started always elevating the context in the REST API layer before calling the database.","commit_id":"2ce720bb89fd042e118c62532e2440e1a7369a5a"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"b8d1ab62ce7fbc17e3881dcc016c1a9d6424b1bc","unresolved":false,"context_lines":[{"line_number":367,"context_line":"Documentation Impact"},{"line_number":368,"context_line":"\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d"},{"line_number":369,"context_line":""},{"line_number":370,"context_line":"We get a much improved sample policy file, because its clear there are no"},{"line_number":371,"context_line":"checks of the project_id in the default policy file."},{"line_number":372,"context_line":""},{"line_number":373,"context_line":"References"}],"source_content_type":"text/x-rst","patch_set":21,"id":"9ff52f3f_052496c5","line":370,"updated":"2017-04-12 23:39:49.000000000","message":"Well, in Queens when we drop a bunch of stuff, right? Because in Pike I thought you were saying we wouldn\u0027t drop anything from the policy file for backward compatibility but it\u0027s unclear to me if what\u0027s in the policy file is still honored or not, i.e. the overrides.","commit_id":"2ce720bb89fd042e118c62532e2440e1a7369a5a"}]}
