Commit Graph

121 Commits

Author SHA1 Message Date
Stephen Finucane 5d2ab6c63b db: Replace use of Query.get()
Resolve the following LegacyAPIWarning warning:

  The Query.get() method is considered legacy as of the 1.x series of
  SQLAlchemy and becomes a legacy construct in 2.0. The method is now
  available as Session.get()

Change-Id: I30d0bccaddff6a1d91fcd5660f490f904e7c8965
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2023-02-28 17:26:39 +00:00
Vishakha Agarwal 4530041931 Remove six usage
This repo does not support Python 2 anymore, so we don't need
six for compatibility between Python2 and 3, convert six usage to Python
3 code.

Change-Id: Icba56808f38277b27af2ae5aac4b8507dee71b3b
2020-01-30 06:06:51 +00:00
Lance Bragstad 87a39635eb Convert policy API to flask
Migrate the policy APIs to use flask-native dispatching.

Change-Id: I03fc72b19e85df711b213c1fe47b30b3f9f91d6c
Partial-Bug: #1776504
2018-08-31 07:14:32 +00:00
Morgan Fainberg bb3b15bbf0 Implement base for new RBAC Enforcer
Create the base implementation of the RBAC enforcer with compat code
for the legacy mechanism via @protected decorators.

Change-Id: I80662d9b23e706b720d56670cb849318e951a3b4
Parital-Bug: #1776504
2018-06-27 22:38:06 +00:00
Morgan Fainberg 4ec6bc5a44 Convert Keystone to use Flask
Basic conversion of Keystone's core application to flask framework.

This doesn't add much in the way of flask-specific-isms but should
get keystone running directly under flask. This implementation does
not use paste-deploy.

Change-Id: Ib4c1ed3f645dd55fbfb76395263ecdaf605caae7
2018-06-04 20:14:41 -07:00
Lance Bragstad 822aff1ba5 Use keystone.common.provider_api for policy APIs
This change converts the usage of self.<provider_api> to
keystone.common.providers_api.ProviderAPIs.<provider_api> in manager
and controller logic. This is the correct way to reference
providers from other managers and controllers now that dependency
injection has been eliminated.

Change-Id: Ieea66d86d6d28ac105c4c39bdea1d05aec8e0c46
2017-12-27 17:10:20 +00:00
Morgan Fainberg 81f9fe6fed Remove Dependency Injection
Refactors all of keystone's dependency injection to maintain a
single centralized repository of instantiated objects. This
means that we are no longer having to resolve order. All
objects that need to reference the various manager APIs simply
do so via the __getattr__ built into the Manager common object
or the ProviderAPIMixin object.

This is also the first step towards correcting our tests to
where they cannot run "load_backends" multiple times.

This forces any/all managers to properly run super()
as the way to register the api is via __init__.

This eliminates all use of the @dependency.requires and
@dependency.provides decorators, simplifying the objects
all around.

Any instantiations of a Manager after keystone is running
will now generate an error, ensuring everything for keystone
is running before handling requests. An exception is for
CLI and CLI tests, as the CLI may directly instantiate
managers and will not lock the registry.

Change-Id: I4ba17855efd797c0db9f4824936b49e4bff54b6a
2017-12-13 10:59:39 -08:00
Matthew Edmonds 621ea65b96 Deprecate policies API
The policies API should never be used. This marks it deprecated in
the API reference so that operators do not waste time looking at it.
It also logs a deprecation warning if the API is called.

Change-Id: I816997826e931a253777145e2c5f894e39182a8f
2017-11-02 14:59:53 -04:00
chenaidong1 bdf47dd491 Policy exception
When fail to query policy information by policy_id(in
policy\backends\sql.py Policy::_get_policy function), it will raise
'exception.PolicyNotFound(policy_id=policy_id)', the deleted code is
redundant if all it does is catch the same exception
and then re-throw it.


Change-Id: I3d4f7175764798449a3efe787af58dc2ea99fc1f
2017-09-07 00:47:44 +00:00
Feng Shengqin 19559b69c0 Remove unused CONF
Change-Id: Ie748beb4236b13508f66b396efbeca4965d3da14
2017-04-22 15:22:05 +08:00
Jenkins 39c6b0ff53 Merge "Make use of Dict-base including extras explicit" 2017-03-31 20:11:14 +00:00
Anthony Washington c734b58581 Policy in code
Adding the beginning implementation for registering and using
default policy rules in code. Rules are defined in the new
policies module and added to the return list __init__.py.
Default policies can now be maintained in code and registered
via listing mechanisms in the policies module. As we go, we
can remove the duplicated default policies from our policy.json
file.

This commit specifically:
- Creates a new module called `policies` to hold our in code defaults.
- Ensure we pass our in code policy list to our policy ENFORCER.
- Add base policy module for common policy rules.
- Add service default policy module for policy rules.
- Add endpoint default policy module for policy rules.
- Add regions default policy module for policy rules.

partially-implements blueprint policy-in-code
Co-Authored-By: Richard Avelar csravelar@gmail.com
Change-Id: Ic47b1e8b0d479032d8a7b9891ed9800be7036d94
2017-03-22 22:19:58 +00:00
Morgan Fainberg dce7c52de9 Make use of Dict-base including extras explicit
This change replaces the use of DictBase with the ModelDictMixin
for any SQL models that do not contain an extra column and renames
the DictBase to a more descriptive name of ModelDictMixinWithExtras.

A Docstring has been added indicating the continued usage of
ModelDictMixinWithExtras should not be done for any "new"
models.

Change-Id: I9a4767cacf7620e878df70084060f3e43e1318df
2017-02-06 19:15:15 -08:00
Jenkins 83bd595b22 Merge "Pass initiator to Manager as a kwarg" 2016-10-09 02:57:43 +00:00
Jenkins eb55c2c9f1 Merge "Move audit initiator creation to request" 2016-10-08 00:58:51 +00:00
Lance Bragstad 86229b3e75 Pass initiator to Manager as a kwarg
Keystone's various Manager classes typically handle the sending of
a notification. In order to send the notification an `initiator` is
needed. All Manager CRUD methods typically ask for this as a kwarg
since it's not required in all cases.

Most of the controller layers pass the initiator value as a
positional argument. This commit makes it so the controller passes it
as a kwarg since that's how the Manager class method signature
describes it.

Change-Id: Ic805f6ea2767c9c5cf01aa04ad554773b9cc8c39
2016-10-07 15:20:45 +00:00
Jamie Lennox 9117e45d6e Move audit initiator creation to request
The audit initiator is basically a context with all the information
about the current operation available. This information is all gathered
from the request and context so we can simplify its generation by moving
it onto the request object.

Change-Id: If91eacd3e07e0d9cd825f92b06c0ac819b3daf8c
2016-10-05 11:42:03 +11:00
Steve Martinelli 810e15689b Remove stable driver interfaces
bp removed-as-of-ocata

Change-Id: I4672cf7d9d72ef725212085972dbcd90db0e47cf
2016-09-28 17:18:37 +00:00
Nam Nguyen Hoai 9488ec53ad Fix formatting strings in LOG.debug
Uses a variable to hold the log message to make the code a
little easier to read.

Change-Id: I4a1759cb12b1c058d553246b64aa5012134674f3
2016-09-21 15:22:45 +00:00
dineshbhor d0328e3293 Replace OpenStack LLC with OpenStack Foundation
Change-Id: I08ad2fad6122734cbcc5842c0b6f76c5f680b69c
Closes-Bug: #1214176
2016-07-22 15:10:35 +05:30
Lance Bragstad 8ff6b0ea51 Move request validation inline
This commit moves all the decorated call to validate request inline with the
method. This is one way we can lazily validate requests - which allows us to
pick validation configuration options specifed in config.

Change-Id: Iee71fb3c34d296427cd485180dacb6bf02581845
2016-07-08 20:22:33 +00:00
Jamie Lennox 3dd17505d0 Pass request to build_driver_hints
Pass the request object through to the build_driver_hints function so
that it can use request.params instead of context.query_string.

This shows the problem with the domain_id filter in list roles. For
whatever reason the driver doesn't filter on domain_id=None by default
so we need to add this filter manually. Because we can no longer
influence the query string we add it to the hints object directly if the
param is not set.

Change-Id: I732c603a24f6b884820ee6837d4c0f752d77987d
2016-07-07 13:48:55 +10:00
Dolph Mathews d9c6b50a3a Replace keystone.common.config with keystone.conf package
keystone.common.config is 1200+ lines of super dense, merge-conflict
prone, difficult to navigate, and finicky to maintain code. Let's follow
nova's lead and break it down into more manageable modules.

This patch creates a new Python package, keystone.conf, and moves all of
our configuration options into it, mirroring nova's nova.conf package.

There are a couple special modules in keystone.conf introduced here as
well:

- keystone.conf.__init__: This causes all of Keystone options to be
  registered on import, so consumers of keystone.conf don't have
  races with config initialization code while trying to use
  oslo_config.cfg.CONF directly (keystone.conf replaces all uses for
  oslo_config.cfg.CONF in keystone).

- keystone.conf.base: Keystone's [DEFAULT] group options. I'd prefer
  this to be called 'default.py', but I'm just copying nova's lead here.

- keystone.conf.opts: The entry point for oslo.config itself.

- keystone.conf.constants: There are a few constants (deprecation
  messages, default paths, etc) that are used by multiple configuration
  modules, so they need to live in a common place.

Change-Id: Ia3daffe3fef111b42de203762e966cd14d8927e2
2016-06-24 17:02:15 +00:00
Jamie Lennox da6ea7e224 Pass a request to controllers instead of a context
Instead of the unformed context dictionary pass a full request object
with access to the context_dict so that existing functions still work.
After this we can replace smaller usages of the context dict with
functions and properties on the request directly.

Change-Id: Ibe822ed7c76a24a7d31d98ce62f873a01e5fb213
2016-06-08 14:56:52 +10:00
Jenkins eb7c0e340a Merge "Restructure policy abstract driver" 2016-04-29 22:08:00 +00:00
Samuel de Medeiros Queiroz 92ece11d01 Restructure policy abstract driver
Change I5ff9c4e4b6d64750f5db2a73cc4317358aea0649 restructured the
identity subsystem. As part of the change, the abstract driver
was extracted to identity/backends/base.py

This change does the same for the policy subsystem.

Partial-Bug: 1563101
Change-Id: Id2a6e9d43724a7ffe95f097a9876b2320f8f01f8
2016-04-29 19:25:54 +00:00
Navid Pustchi 2c4f948db0 Fix D400 PEP257
Currently tox ignores D401.
D400: First line should end with a period.
This change removes it and make keystone docstring compliantwith it.

Change-Id: I9a9520e69701718ff471eebbcc52199dacdd9c68
2016-04-21 15:25:34 +00:00
Navid Pustchi aabc213040 Fix D401 PEP8 violation.
Currently tox ignores D401 (401: First line should be in imperative mood).
This change removes it and make keystoneauth docstring compliantwith it.

Change-Id: I136cf810f47c4c19f29216907a63f226930b5082
Partial-Bug: 1570049
2016-04-14 20:08:52 +00:00
Grzegorz Grasza 0e156737d0 Use the new enginefacade from oslo.db
EngineFacade is deprecated. This partially switches keystone to
use oslo.db.sqlalchemy.enginefacade. 'get_session' and 'get_engine'
methods are still used in sql migrations and related tests.

Change-Id: I221232d50821fe2adb9881f237f06714003ce79d
Partial-Bug: #1490571
2016-02-24 08:20:12 -08:00
Samuel de Medeiros Queiroz e64a1b5891 Remove exposure of routers at package level
Keystone API routers are exposed at their package
level (in __init__.py files). This causes them to
be unnecessarily executed each time something
whithin that package is used.

For example, simply importing
keystone.federation.constants would make the
federation routers code to be executed.

This patch remove routers exposure from package
level and import them directly in services.py,
which is the single place that needs them.

Change-Id: If68184c871ac77659ad2e64aa5f0aafac7a4bf70
2015-12-03 15:06:56 -03:00
Dave Chen 5070039812 Using the right format to render the docstring correctly
There are several issues in the docstring, the format is not
correct, not using the full path of class etc.

This patch corrects all of them, so the docstring will be rendered
correctly.

Change-Id: I04d5818f38b5e75b6f6197ef5e13dcd64ed91bf4
2015-11-24 04:37:14 +00:00
Dolph Mathews bf08563778 Fix D208: Docstring over indented. (PEP257)
No other PEP257 violations were addressed here.

Change-Id: I567fb5681b043b26bea3d358d7a47d88c02249a0
2015-10-16 17:16:10 +00:00
Vivek Dhayaal ba317dedd8 Stable Keystone Driver Interfaces
Extended support for versioned driver classes to the rest of the
backends based on the design of the initial support for catalog backend @
https://review.openstack.org/#/c/218481/

partially Implements bp stable-driver-interfaces

Change-Id: I0078f6dc32932beb6db534ecf22b160097c5a090
2015-09-02 06:10:26 +00:00
Brant Knudson 6817d66bd2 Use stevedore for backend drivers
The Stevedore library is used for loading backend drivers rather
than using importutils. This provides a level of indirection for
deployers/packagers.

The importutils method of loading drivers is still supported, but
it's deprecated.

bp stevedore

Change-Id: Id77ebf7056987ff1d3b9f62fab411845e63c86c3
2015-04-28 16:40:23 -05:00
Steve Martinelli 3ec2418673 Use oslo.policy instead of incubated version
* pull in oslo.policy
* account for changes to Enforcer initialization
* account for changes to config options

partially implements bp graduate-policy

Change-Id: Ia23afda5acf92cdc4578ec4c85821603c56d3097
2015-03-05 18:53:03 -05:00
Steve Martinelli ffcc81b7a6 Get initiator from manager and send to controller
Using the WSGI context that is available at the manager layer,
we can get the Initiator content we need and forward it to the manager
classes.

Co-Authored-By: Morgan Fainberg <morgan.fainberg@gmail.com>
partially implements bp: cadf-everywhere

Change-Id: I6b7885d29cd733c5040bea6003dd93607cb5821e
2015-03-02 13:24:14 -05:00
Jenkins ec257c802e Merge "Publicize region/endpoint/policy/service events" 2015-02-21 01:55:06 +00:00
Brant Knudson feb279d1dc Consistently use oslo_config.cfg.CONF
Keystone modules used different sources of the CONF global so were
inconsistent. All modules should use CONF from oslo_config.cfg.

Change-Id: I60c8d2c577d37b9b8a367b46596154ce6c49fff4
2015-02-18 09:04:05 -06:00
Steve Martinelli 3038e976b4 Publicize region/endpoint/policy/service events
Start publicizing events for on create/update/delete events
for region/endpoint/policy/service. There was no reason to
not publicize them.

partially implements bp: cadf-everywhere

Change-Id: I7498824d0f67e752b48808d279e4faee6f914253
2015-02-17 20:14:09 +00:00
Steve Martinelli 0f61b11141 Use oslo.log instead of incubator
Most of changes are just replacing

from keystone.openstack.common import log
  with
from oslo_log import log

There are some other specific changes that had to be made
  * Initialize logger in keystone/config.py

Change-Id: I859edb71c434051ffe7f34c16018b738ddb71e3b
2015-02-14 05:34:52 +00:00
Lance Bragstad 383422f243 Provide useful info when parsing policy file
When parsing the policy.json file we should provide a message that helps
the user or deployer understand there was an issue with the policy file,
and that they should make sure the policy.json file is valid JSON.

Change-Id: I63bdb6d8f03a0510e34b7e10cec25263e7c6c63c
Closes-Bug: #1177623
2014-10-29 20:38:54 +00:00
Dave Chen 8243f821cd Correct the code path of implementation for the abstract method
Change-Id: Ib32c096b490f98259b5d1421df97549e506e501f
2014-10-20 22:51:56 +08:00
Lance Bragstad 28f60cfa69 Implement validation on Policy V3 API
Use JSONSchema to validate create and update operations on V3
Policy API.

Change-Id: I43146fce5018330eba2119194325bde29e4759bb
bp: api-validation
2014-08-31 03:39:49 -04:00
Brant Knudson 50f74cb947 Change the sub-routers to provide JSON Home data
The sub-routers also need to provide JSON Home data for the
resources that they add.

bp json-home

Change-Id: Icbbd36a468d4fa7627ad7686f08fe98bbf3b51a4
2014-08-26 09:57:15 -05:00
Henry Nash 8612a54f91 Add notifications for policy, region, service and endpoint.
The endpoint policy extension will need to ensure stale
associations are removed on deletion of these entities. Delete
events are already generated for endpoints. For completeness,
create and update notifcations for these entities have also
been implemented.

Partially implements: bp endpoint-policy
Change-Id: I5de15459f5b577955056ecc166b450963e85bbc9
2014-08-21 14:53:52 +01:00
Brant Knudson dd70a5548e Class for V3 router packages
The V3 routes were being added by the append_v3_routers function in
each controller package, so the only way state could be stored is in
a global variable which makes unit testing difficult. With this
change, the append_v3_routers functions are put into a class in each
package. This will eventually be used to store JSON Home data.

bp json-home

Change-Id: I744a4c82dc84bb1a8d29d0314e3c51cc43c077a2
2014-08-02 16:15:21 -05:00
Juan Antonio Osorio b44858da22 Introduce pragma no cover to asbtract classes
Since the unimplemented methods for abstract classes are not meant to be
actually used, they shouldn't be included in the code coverage
calculation. Thus, to address this I introduced the pragma "no cover" to
these classes.

Change-Id: Id239a2eb42d8288764b8f374d5d13ebd37af5a7d
2014-07-17 16:31:24 +03:00
David Stanek 76baf5b691 Adds hacking check for debug logging translations
bp more-code-style-automation

Change-Id: Id54f322f00b04a165bb4a7b1e24f95bb72b7f068
2014-06-27 01:55:48 +00:00
David Stanek 05f3c12107 Removes unused db_sync methods
In reviewing https://review.openstack.org/79211 we discovered that none
of the db_sync methods are called anymore.

Change-Id: Ie9714822efd06ba51654ac3aa3b93886cae24d6f
2014-04-02 20:15:40 +00:00
Brant Knudson de2c89cbef Safer noqa handling
"# flake8: noqa" was used in several files. This causes the
entire file to not be checked by flake8. This is unsafe, and
"# noqa" should be used only on those lines that require it.

E712 doesn't honor #noqa, so work around it by assigning True to a
variable.

Change-Id: I1ddd1c4f4230793f0560241e4559095cb4183d71
2014-03-27 18:52:07 -05:00