Commit Graph

26 Commits

Author SHA1 Message Date
ricolin 5971243169 Support enables rbac policies new defaults
The Magnum service allow enables policies (RBAC) new defaults and scope by
default. The Default value of config options ``[oslo_policy] enforce_scope``
and ``[oslo_policy] oslo_policy.enforce_new_defaults`` are both to
``False``, but will change to ``True`` in following cycles.

To enable them then modify the below config options value in
``magnum.conf`` file::

  [oslo_policy]
  enforce_new_defaults=True
  enforce_scope=True

reference tc goal for more detail:
https://governance.openstack.org/tc/goals/selected/consistent-and-secure-rbac.html

Related blueprint secure-rbac

Change-Id: I249942a355577c4f1ef51b3988f0cc4979959d0b
2023-08-30 00:35:24 +08:00
Spyros Trigazis cd113dfc0c Remove use of tenant in common/context.py
Tenant has been removed from context.
Fixes UTs and pep8.

Signed-off-by: Spyros Trigazis <spyridon.trigazis@cern.ch>
Change-Id: I10daa22b614aab456b837c03278eb04da0355ff7
2022-03-18 13:20:46 +00:00
Ricardo Rocha c57bc86384 Deprecate usage of tenant and user in context
Update usage of tenant to project_id and user to user_id when handling context
fields. This drops deprecation warnings.

Change-Id: I8001be34bcc25678ed99b6b6717ad170ae6d2d77
2018-02-06 14:00:43 +00:00
Vijendar Komalla 54152970e1 Set is_admin flag correctly in RequestContext
Currently is_admin flag is always False. As a result
some of the admin operations are not working.
For example, quotas-list is not listing all the
user quotas.
This change sets the flag correctly based on the
roles assigned to the user and policies defined
in policy.json.

Change-Id: I01534ccf1cf1e635282db497e0e026bea19c3bd2
Closes-Bug: #1660843
2017-03-03 03:37:08 +00:00
Tovin Seven 32d088b2c1 Integrate OSProfiler in Magnum
* Add osprofiler wsgi middleware. This middleware is used for 2 things:
  1) It checks that person who wants to trace is trusted and knows
     secret HMAC key.
  2) It starts tracing in case of proper trace headers
     and adds first wsgi trace point, with info about HTTP request

* Add initialization of osprofiler at start of service
  Currently that includes oslo.messaging notifer instance creation
  to send Ceilometer backend notifications.

* Traces HTTP/RPC/DB API calls

Demo: https://hieulq.github.io/cluster-create-false-new-html.html

Co-Authored-By: Hieu LE <hieulq@vn.fujitsu.com>
Implements: blueprint osprofiler-support-in-magnum
Change-Id: I7d68995aab81d365433950aada078ef1fcd5469b
2017-01-24 07:43:31 +07:00
Hongbin Lu a60529cb11 Fix the incorrect initialization of context roles
We should pass roles to oslo_context to initialize instead of
manually set it.

Change-Id: Ice05204d789bb1770ab6605f06d670c5fc7c6726
Closes-Bug: #1654813
2017-01-07 23:35:08 -06:00
Hieu LE 3a6a7cd8d5 Centralize config option: urlfetch and periodic
Centralize config option of urlfetch and periodic section.
Replace oslo_config cfg to magnum.conf.

Clean up some oslo_config import_opt and use magnum.conf.

Finish Implements: blueprint centralize-config-magnum
Change-Id: I11fb85159b260865beae9686734ca102ebc3154b
2016-10-11 04:04:38 +00:00
Jaycen Grant 729c2d0ab4 Rename Bay DB, Object, and internal usage to Cluster
This is patch 3 of 3 to change the internal usage of the terms
Bay and BayModel.  This patch updates Bay to Cluster in DB and
Object as well as all the usages.  No functionality should be
changed by this patch, just naming and db updates.

Change-Id: Ife04b0f944ded03ca932d70e09e6766d09cf5d9f
Implements: blueprint rename-bay-to-cluster
2016-09-08 13:01:12 -07:00
Johannes Grassler f895b2bd09 Fix global stack list in periodic task
The periodic task unneccessarily lists Heat stacks in the
global tenant (across all tenants) which the Magnum service
user may lack permission for. Also, the most restrictive way
to let it use global stack-list is chose a Keystone role and
open that operation to any user in any project holding that
role.

This commit substitutes a direct lookup of all bays' stack_id
attributes for this global stack list. This direct lookup will
yield the same net result. In order to get the neccessary
permissions it will use each bay's stored Keystone trust to
act on behalf of the bay's creating user.

Co-Authored-By: Jiri Suchomel <jiri.suchomel@suse.com>
Closes-Bug: #1589955
Change-Id: I67b176c137c463e37e037970cc4e468d51db30c9
2016-07-27 10:11:51 +02:00
Yang Hongyang b0b3a3db00 Init oslo_context before magnum context init
Roles is added as a member of oslo.context since oslo 2.2.0
https://review.openstack.org/#/c/271928/
This causes magnum gate fail because roles is overwrited by
oslo_context. Let's init oslo_context first and then make
our local changes.

Change-Id: Iac8c568bd49fbc66d2d65c9b6083bc9895a8069c
Closes-Bug: #1549694
2016-02-25 21:39:06 +08:00
Hua Wang a01138ab91 Read auth_uri from config file and remove is_public_api
1.auth_url can not be obtained from request headers, it can only
be read from config file.
2.is_public_api is not used, so let's remove it from context.

Change-Id: Ie7207ef5311e3168b64c47aef4041ed2dd0e39c6
Partially-Implements: blueprint generate-keystone-trust
2015-10-13 21:20:26 +08:00
Surojit Pathak deae4e44b0 Modify admin_api policy rule
Magnum API's magnum_service:get_all is enforced by admin_api.
Modifying the rule to use context_is_admin. Also changing the to_dict()
call to include change in roles.

Change-Id: I44dda27857945dfd3ad43fa28ea458ce2966388c
Closes-Bug: #1503402
2015-10-09 20:12:58 +00:00
Hua Wang 86ed292e52 Add roles to context
We use oslo.policy to check the policy. Oslo.policy needs
roles held for the given token scope [1]. So we should add roles
to context.

[1]http://docs.openstack.org/developer/oslo.policy/
   api/oslo_policy.html#generic-checks

Change-Id: I95afbf57f185ca1db9c68781c2fcd78cbafc1e17
Closes-Bug: #1489832
2015-08-24 23:55:20 +08:00
Hongbin Lu fa5bcee4ab Move 'all_tenants' options to context
In before, bay and x509keypair supported list resources from all
tenants. It is desirable to generalize this capability while reducing
duplicated codes. Therefore, moving 'all_tenants' options to context.

Change-Id: Icfe31a6f2ac2e21fa7f377e244764f10892d25c7
Partially-Implements: blueprint autoscale-bay
2015-08-27 18:22:35 -04:00
Eli Qiao fd57cb4372 Add periodic task to sync up bay status
This patch adds periodic task `sync_bay_status` which will be used for syncing
bay's status from heat stack, we will pull bays which status in
[bay_status.CREATE_IN_PROGRESS,
 bay_status.UPDATE_IN_PROGRESS,
 bay_status.DELETE_IN_PROGRESS]
which are all in a temporary status, and try to sync up the status with heat's
stack.

status changes will be like this:

bay_status              stack_status           sync up bay_status to
----------              ------------           ---------------------
CREATE_IN_PROGRESS      CREATE_COMPLETE        CREATE_COMPLETE
UPDATE_IN_PROGRESS      UPDATE_COMPLETE        UPDATE_COMPLETE
DELETE_IN_PROGRESS      DELETE_COMPLETE        DELETE_COMPLETE

CREATE_IN_PROGRESS      CREATE_FAILED          CREATE_FAILED
UPDATE_IN_PROGRESS      UPDATE_FAILED          UPDATE_FAILED
DELETE_IN_PROGRESS      DELETE_FAILED          DELETE_FAILED

CREATE_IN_PROGRESS      Not Found              CREATE_FAILED
UPDATE_IN_PROGRESS      Not Found              UPDATE_FAILED
DELETE_IN_PROGRESS      Not Found              destroy

Partial-Implements: blueprint add-periodic-task
Co-Authored-By: ShaoHe Feng <shaohe.feng@intel.com>
Change-Id: Ie9cc4d3f03c7938a8d988010604da79c9b8a22fd
2015-07-16 08:35:16 +08:00
Eli Qiao 42ec89f913 Add make_admin_context to Magnum context
make_admin_context will return a admin context which can be used to fake
a context which will be use for periodic task.

Partial-Implements: blueprint add-periodic-task
Co-Authored-By: ShaoHe Feng <shaohe.feng@intel.com>
Change-Id: I92ff05e6e40ea8bd0c08ae279b70ef5f1a7e70be
2015-06-24 16:18:09 +08:00
Dane LeBlanc 617b772e55 Modify magnum api context to use user_name and project_name
Problem description:
If DevStack is used to instantiate the magnum plugin, and the
devstack localrc/local.conf has the default values for:
   LOG_COLOR (default value = True)
   SYSLOG (default value = False)
then upon startup (i.e. running DevStack's stack.sh), the magnum devstack
lib calls the DevStack common setup_colorized_logging function, but
without passing the optional 'project_var' and 'user_var' arguments to
this function. As a result, the setup_colorized_logging
function uses its default values of "user_name" and "project_name"
when it defines the logging_context_format_string (which in turn gets
configured in /etc/magnum/magnum.conf). The problem is that "user_name"
and "project_name" are not defined in the API context used by Magnum,
so that whenever the magnum plugin does a logging call, a KeyError
exception for the non-existant key "user_name" is generated.

Fix description:
The fix is to modify the Magnum context to use "user_name" and
"project_name" attributes to be consistent with the default context
format string set up by DevStack.

Change-Id: Ia0c34899609735ff9d8b4597101e004e2684657e
Closes-Bug: #1464376
2015-06-15 18:27:15 -04:00
Eli Qiao 7c2f1016a1 Fix RequestContext's to_dict method
We need to call oslo_context.RequestContext to_dict method in magnum's
RequestContext method.

Closes-Bug: #1462261
Change-Id: Ibe866bdd9ddb06566f7b1967475a4cdd7ef2d936
2015-06-05 18:24:03 +08:00
Jay Lau (Guangya Liu) f416aa6955 Remove # -*- encoding: utf-8 -*- from some python files
Some python files do not need to encode in utf-8, so just remove
"# -*- encoding: utf-8 -*-" from those files.

Change-Id: Iafdf4eda876b6599b75c7710e69f62918842ebec
Closes-Bug: #1422067
2015-02-15 14:33:56 +08:00
OTSUKA, Yuanying 2306534079 Don't use deprecated auth header
"X-Tenant-Id" and "X-Tenant" auth header is deprecated in
keystonemiddleware [1]. So this remove these header and replace to
"X-Project-Id".
And this also flesh up around RequestContext.

[1]: https://github.com/openstack/keystonemiddleware/blob/master/keystonemiddleware/auth_token.py#L371

Change-Id: I5f3adcb6eaed4fe75da6ec77c367a2b6c785ae5d
2015-01-30 12:08:50 +09:00
Andrew Melton 5999adfa0d Pull RequestContext Patching Into Test Base
The new patching only ensures that auth_token_info is properly
set up by default. A real RequestContext is returned, and it is
passed through to_dict and from_dict to ensure there are no
assumptions made that will not work through RPC.

If necessary, tests can still return a mock context by setting
a return_value or side_effect on self.mock_make_ctxt.

Change-Id: I6369e0bd89d83a5ea3ddde2b35423233fee18327
2015-01-28 10:37:50 -08:00
Andrew Melton 4b3712bddd Ensure auth_token_info present on RequestContext
Ensure that auth_token_info is present on dictionary representation
of RequestContext otherwise it will get lost through RPC calls.

Change-Id: I0a52db38c67018239f99e39d330dd4386da41371
Closes-bug: #1415173
2015-01-27 12:10:35 -08:00
OTSUKA, Yuanying 2e7b9046a8 Fix RequestContext attributes
'auth_url', 'auth_token_info' and 'trust_id' is required to create heatclient.
So this commit added these.

Change-Id: If17c87770f2e4d93dae5e1262faa5b44cc5cfdef
2014-12-25 11:12:58 +09:00
Abhishek Chanda 92e3ebee20 Migrate to oslo.context
Remove deprecated oslo incubator code

Change-Id: Iee16111fc86aef83603251aedf6d58f6da78fc92
2014-12-14 16:38:34 +05:30
Steven Dake 3f85ccce3a Copy ironic/common files to magnum/common for RPC server
These are straight copies of ironic/ironic/common files needed
for the RPC server.

Change-Id: If493eaee919e55b2e5f85f2411c0b0d813f21bde
2014-12-06 17:26:03 -07:00
Steven Dake 62bfbf6045 Add Keystone authentication to rest API
Authenticate requests via keystone to the REST API.

Change-Id: Ie45e5325c2f9cd892c60ff37acfcd1ceecc82e32
2014-11-19 11:24:33 -07:00