Commit Graph

7 Commits

Author SHA1 Message Date
Armando Migliaccio ca751a1486 Spin off context module
NeutronLibImpact

Partially-implements: blueprint neutron-lib

Change-Id: I48cf45dc1b07035d952152eac2548a3bd9fc2832
2017-03-06 16:25:29 +00:00
Ann Kamyshnikova 4f17f70089 Stop using legacy facade
Introduce get_reader_session() and get_writer_session()
and replace get_session() with them.
Mark get_session as depricated.

Stop using get_engine from legacy facade. Use writer engine for
places where it is required.

Partially-Implements blueprint: enginefacade-switch

Change-Id: I28b741bfa27bf04cbe273586e6e3e00e14fbe683
2017-01-19 13:02:33 +04:00
Jamie Lennox 2e621eeb1c Use to_policy_values for policy enforcement
Use the common policy values for all services when enforcing policy
decisions. We add all possibly used policy values to maintain backwards
compatibility.

Change-Id: Ie1d0739ab4dfb0654d8767693dbdba5cd52a30b2
Closes-Bug: #1602081
2016-11-30 05:02:46 +00:00
Victor Stinner d3bef03040 Support Unicode request_id on Python 3
The oslo.context change If48ee7f4d1c113f1f26b3b1698c6b055807b950f will change
request_id type on Python 3 from bytes to str. This change prepares Neutron for
this change.

Blueprint: neutron-python3
Change-Id: Ia5203581db120bb4f8e24fd752d6ae14e6558505
2015-11-27 16:21:16 +01:00
Cyril Roelandt 619ac1c91a Python 3: fix test_context
In Python 3, b'...'.startswith must be given bytes.

Change-Id: I4e83685ac6119db6f16d693df37955620271082f
Blueprint: neutron-python3
2015-07-27 16:57:08 +02:00
Salvatore Orlando 734e77365b Remove get_admin_roles and associated logic
get_admin_roles was introduced so that contextes generated from
within plugins could be used for policy checks. This was the case
up to the Havana release as several plugins invoked the policy
engine directly to authorize requests.

This was an incorrect behaviour and has now been fixed, meaning
that get_admin_roles is no longer need and can be safely removed.
This will result in a leaner and more reliable codebase. Indeed the
function being removed here was the cause of several bugs where the
policy engine was initialized too early in the server bootstrap
process.
While this patch removes the feature it does not remove the
load_admin_roles parameter from context.get_admin_context. Doing so
will break other projects such as neutron-lbaas. The parameter is
deprecated by this patch and an appropriate warning emitted.

As a consequence neutron's will now no longer perform policy checks
when context.is_admin=True. This flag is instead set either when
a context is explicitly created for granting admin privileges, or
when Neutron is operating in noauth mode. In the latter case every
request is treated by neutron as an admin request, and get_admin_roles
is simply ensuring the appropriate roles get pushed into the context
so that the policy engine will grant admin rights to the request.
This behaviour is probably just a waste of resource; also it is not
adding anything from a security perspective.

On the other hand not performing checks when context.is_admin is
True should not pose a security threat either in noauth mode or
with the keystone middleware. In the former case the software keeps
operating assuming admin rights for every requests, whereas in the
latter case the keystone middleware will always supply a context
with the appropriate roles, and there is no way for an attacker
to trick keystonemiddleware into generating a context for which
is_admin=True.

Finally, this patch also does some non-trivial changes in test_l3.py
as some tests were mocking context.to_dict ignoring the is_admin flag.

Closes-Bug: #1446021

Change-Id: I8a5c02712a0b43f3e36a4f14620ebbd73fbfb03f
2015-06-09 11:12:47 +02:00
Maru Newby 1105782e39 Reorganize unit test tree
This change ensures that the structure of the unit test tree matches
that of the code tree to make it obvious where to find tests for a
given module.  A check is added to the pep8 job to protect against
regressions.

The plugin test paths are relocated to neutron/tests/unit/plugins
but are otherwise ignored for now.

Change-Id: If307593259139171be21a71c58e3a34bf148cc7f
Partial-Bug: #1440834
2015-04-06 23:28:31 +00:00