Commit Graph

137 Commits

Author SHA1 Message Date
Dave Wilde a8366c4827 Add ability to create users and projects from keystone-manage
This adds the ability to create users and projects directly from
keystone-manage.  We also add the ability to specify specific UUIDs
for both users and projects via the creation functions.

Change-Id: Icd193eff25556d21ec26bb29908b8ad6548fdc91
2024-03-12 08:06:35 -05:00
Rafael Weingärtner 14ac08431f Keystone to honor the "domain" attribute mapping rules.
We propose to extend Keystone identity provider (IdP) attribute mapping
schema to make Keystone honor the `domain` configuration that we have
on it.

Currently, that configuration is only used to define a default domain
for groups (and then each group there, could override it). It is
interesting to expand this configuration (as long as it is in the root
of the attribute mapping) to be also applied for users and projects.

Moreover, to facilitate the development and extension concerning
attribute mappings for IdPs, we changed the way the attribute mapping
schema is handled. We introduce a new configuration
`federation_attribute_mapping_schema_version`, which defaults to "1.0".
This attribute mapping schema version will then be used to control the
validation of attribute mapping, and also the rule processors used to
process the attributes that come from the IdP. So far, with this PR,
we introduce the attribute mapping schema "2.0", which enables
operators to also define a domain for the projects they want to assign
users. If no domain is defined either in the project or in the global
domain definition for the attribute mapping, we take the IdP domain
as the default.

Change-Id: Ia9583a254336fad7b302430a38b538c84338d13d
Implements: https://bugs.launchpad.net/keystone/+bug/1887515
Closes-Bug: #1887515
2024-01-16 08:54:56 -03:00
Pete Zaitcev d2deab385b Stop pinning pep8 related packages
These practices cause conflicts periodically. Not right now:
the gate is okay with the current values, which this patch
deletes. However, like sun raising in the east it is sure
to happen again. This patch lets workarounds work that the
infra team puts in place. The downside is, we need to fix
the code once in a while as new checks get added.

Change-Id: Ia7a96fb4b6de4251862a8a96c995cefa94dbc271
2023-10-02 15:41:36 -05:00
Abhishek Kekane bbbbd10e48 Add default manager role support to bootstrap command
Added manager role support to bootstrap command.

Closes-Bug: #1951622
Change-Id: I4149e99bdc50194dd4067f5f3e2f3019e48b5a59
2023-08-30 18:20:43 -05:00
Zuul 1ac30ab59f Merge "Add default service role support to boostrap command" 2023-08-04 08:07:44 +00:00
Abhishek Kekane d0eacc4729 Add default service role support to boostrap command
Added service role support to bootstrap command.

Closes-Bug: #1951632
Change-Id: I9cb25a111c84ecb3a09158cbe44b0954df89096c
2023-03-28 17:51:17 +00:00
Stephen Finucane 8c9462f6fa db: Remove legacy migrations
sqlalchemy-migrate does not (and will not) support sqlalchemy 2.0. We
need to drop these migrations to ensure we can upgrade our sqlalchemy
version.

Change-Id: I31ba9e4f129a7cc28744e814b5fd28eb284ae3de
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2023-02-28 17:26:39 +00:00
Stephen Finucane f174b4fa7c sql: Integrate alembic
Switch to alembic for real by integrating it into the 'db sync' command
flow. From a user-facing perspective, things should remain pretty much
the same as before, with the key difference being that version
information (i.e. what's shown by 'keystone-manage db_sync --check' or
'keystone-manage db_version') will now take the form of a hash rather
than an integer. There are a few differences for contributors however.
The changes are described in the included release note and
documentation.

Note that there are a couple of important design decisions here that are
worth examining:

- We drop the idea of the 'data_migration' branch entirely and the
  'keystone-manage db_sync --migrate' command is now a no-op. Neutron
  doesn't do data migrations like we do and yet they manage just fine.
  Dropping this gets us closer to neutron's behavior, which is a good
  thing for users.

- We haven't re-added the ability to specify a version when doing
  'db_sync'. Neutron has this, but the logic needed to get this working
  is complex and of questionable value. We've managed without the
  ability to sync to a version since Newton and can continue to do so
  until someone asks for it (and does the work).

- sqlalchemy-migrate is not removed entirely. Instead, upon doing a
  'db_sync' we will apply all sqlalchemy-migrate migrations up to the
  final '079_expand_update_local_id_limit' migration and dummy apply the
  initial alembic migration, after which we will switch over to alembic.
  In a future release we can remove the sqlalchemy-migrate migrations
  and rely entirely on alembic. Until then, keeping this allows fast
  forward upgrades to continue as a thing.

- Related to the above, we always apply *all* sqlalchemy-migrate
  migrations when calling 'db_sync', even if this command is called with
  e.g. '--expand' (meaning only apply the expand branch). This is
  because there is at most one "real" migration to apply, the Xena-era
  '079_expand_update_local_id_limit' migration, which is an expand-only
  migration. There is no risk to applying the empty "data_migration" and
  "contract" parts of this migration, and applying everything in one go
  results in *much* simpler logic.

Future changes will update documentation and add developer tooling for
(auto-)generating new migrations, a la 'neutron-db-manage revision'.

Change-Id: Ia376cb87f5159a4e79e2cfbab8442b6bcead708f
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2022-06-20 13:29:58 +01:00
Stephen Finucane dce38678fc sql: Prepare for alembic migration
Nothing functional here. We simply switch from using "repo_name"
terminology and move/rename some helper functions. Branches aren't
really a SQLAlchemy-Migrate thing but it's close enough to do.

Change-Id: I005d20ef21b6c8122be90e8afb38abd902fdfc6e
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2022-02-04 19:23:05 +00:00
Stephen Finucane 0b906c6529 sql: Vendor 'oslo_db.sqlalchemy.migration'
This is deprecated and will be removed in a future release of oslo.db.
Even without that stick to prod us, we're going to need to use some of
the sqlalchemy-migrate APIs and it's simpler to talk to this for
everything rather than using oslo.db for some stuff and
sqlalchemy-migrate for the remainder.

Change-Id: Ib25c75a99794a04b6549e6b5184a2029955befc1
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2022-01-24 16:03:44 +00:00
Stephen Finucane 9f42c5ad6a cmd: Remove deprecated '--extension' argument
Remove option from 'db sync' and 'db version' commands of
'keystone-manage'. We also remove handling code for providing '--expand'
and '--migrate' in the same invocation, which isn't possible since
they're in a mutually exclusive group. Finally, we clean some formatting
things up in preparation for the alembic integration.

Change-Id: I198822d6f55353f1adeea9024db67abb24be54c7
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2022-01-21 13:39:30 +00:00
Hervé Beraud 2844a38f7f Stop to use the __future__ module.
The __future__ module [1] was used in this context to ensure compatibility
between python 2 and python 3.

We previously dropped the support of python 2.7 [2] and now we only support
python 3 so we don't need to continue to use this module and the imports
listed below.

Imports commonly used and their related PEPs:
- `division` is related to PEP 238 [3]
- `print_function` is related to PEP 3105 [4]
- `unicode_literals` is related to PEP 3112 [5]
- `with_statement` is related to PEP 343 [6]
- `absolute_import` is related to PEP 328 [7]

[1] https://docs.python.org/3/library/__future__.html
[2] https://governance.openstack.org/tc/goals/selected/ussuri/drop-py27.html
[3] https://www.python.org/dev/peps/pep-0238
[4] https://www.python.org/dev/peps/pep-3105
[5] https://www.python.org/dev/peps/pep-3112
[6] https://www.python.org/dev/peps/pep-0343
[7] https://www.python.org/dev/peps/pep-0328

Change-Id: I2f9d2114b2c5eb66f241646f1896ea17a160e3f3
2020-06-02 20:20:37 +02:00
Colleen Murphy da28046944 Default to bootstrapping roles as immutable
In the previous cycle, the ``--immutable-roles`` option was added to the
bootstrap command as an optional way to opt-in to making the default
roles immutable. Following step 4 of the spec[1], we now make that
behavior the default and additionally offer a way to opt out of it.

[1] http://specs.openstack.org/openstack/keystone-specs/specs/keystone/train/immutable-resources.html#proposed-change

Change-Id: I6b680efb2c87c1d7559ddcc989bbce68456b9a5f
Closes-Bug: #1823258
2020-02-04 14:21:13 -08:00
Zuul b9d9fd47b7 Merge "Use raw formatting for mapping_engine help text" 2019-09-20 10:21:08 +00:00
Colleen Murphy a80d83e76d Add --immutable-roles flag to bootstrap command
This implements Step 2 of the Proposed Change for Immutable
Resources[1].

[1] http://specs.openstack.org/openstack/keystone-specs/specs/keystone/train/immutable-resources.html#proposed-change

Change-Id: I4d99f630cb16e1d58261012e59d3a92c7035734c
Partial-bug: #1823258
2019-09-10 00:03:20 -07:00
Lance Bragstad c453bf16b0 Use raw formatting for mapping_engine help text
The ``keystone-manage mapping_engine`` help text wasn't formatting
an example assertion properly. The example uses newlines but the
default formatter drops them when formatting and printing help text.

Instead, we can set a raw formatter for the ``mapping_engine``
parser so that it includes newlines. This means all help text needs to
be properly formatted in code even though we only need it for a single
option. This commit introduces a raw formatter and adds new lines to
all help text so that it renders the same way as when we were using
the default formatter.

Change-Id: I7f8051e008ffea1ebaa4b6176f3d1a9f8208eaee
2019-08-29 13:26:00 +00:00
Gage Hugo 295b07cc76 Don't throw valueerror on bootstrap
When keystone-manage bootstrap is ran without providing a value
to set as the admin password, keystone-manage will throw an
unhandled ValueError while displaying the proper warning
message.

This change removes the ValueError and simply has the CLI
exit out when this condition is met.

Closes-Bug: #1804700

Change-Id: I4e7d5eeb2e48ff354b44196bd11d62d51a73357b
2019-05-23 14:37:11 +00:00
Lance Bragstad 1abe8a2ec0 Add keystone-manage create_jws_keypair functionality
Thw JSON Web Token provider implementation is going to need keys in
order to issue and validate tokens, very similar to how the fernet
provider operates, but using asymmetric signing instead of symmetric
encryption.

This commit addes a new subcommand to the keystone-manage binary that
creates a ECDSA key pair for creating and validating JWS tokens.

bp json-web-tokens

Change-Id: I9cf5c168bae2a90aba3d696e3f6ce3028998121a
2019-01-31 19:41:25 +00:00
Zuul 02fcd543df Merge "Expose receipt_setup and receipt_rotate command" 2019-01-30 22:33:04 +00:00
Adam Young b4e97a9c92 Adjust Indents to meet PEP8 E117
Change-Id: I724879fc7d55b6c42899a5950133b7021f0f6be6
2019-01-29 13:48:57 -05:00
Zuul 99d1e123df Merge "Optimize fernet token and receipts in cli.py" 2019-01-16 17:01:35 +00:00
Vishakha Agarwal 09ade53c10 Optimize fernet token and receipts in cli.py
This patch is to reduce the duplicate lines of
code.

Change-Id: I8121d66313f0fb4c342e2e5b5c80530fa599429a
2019-01-16 10:08:48 +05:30
wangxiyuan f1501b99e1 Expose receipt_setup and receipt_rotate command
The commands "receipt_setup" and "receipt_rotate" are used for
control receipt keys. They should be exposed to operators.

Update the cli doc in alpha order as well.

Change-Id: Id8f062ce1d713cd029a11fe8fdc81c256a771471
2019-01-14 14:35:10 +08:00
zhufl 7368e5c678 Do not use self in classmethod
cls should be used in classmethod, instead of self.

Change-Id: I3b5bb805a79b25050ed459f85ad25681171aa743
2019-01-09 17:28:00 +08:00
Adrian Turjak 7fa62c823a Fix an issue with double fernet key rotation
When the token and receipt directories don't match perfectly
(e.g. trailing slash vs not), we would get double key rotation.

Use os.path to make sure we are indeed checking for the same path.

Change-Id: I34c5e4891773bcd6a799f3dbfa7174718030c4e4
2018-11-05 22:34:03 +13:00
Zuul c785729efe Merge "Implement auth receipts spec" 2018-11-02 18:30:44 +00:00
Adrian Turjak d9e6c1d4dd Implement auth receipts spec
Adds a new model and provider for receipts which are
very similar to tokens (fernet based), and share the
same fernet mechanisms.

Adds changes to the auth layer to handle the creation,
validation, and consumptions of receipts as part of
the auth process.

Change-Id: Iccb6e6fc7aee57c58a53f90c1d671402b8efcdbb
bp: mfa-auth-receipt
2018-11-02 15:06:19 +01:00
Taishi Roy 57c6f274a9 changed port in argument '--bootstrap-admin-url'
Before keystone needed to be run on two separate ports to accommodate
the Identity v2 API which ran a separate admin-only service commonly
on port 35357. With the removal of the v2 API, keystone runs on port
5000.

Change-Id: I7744f664a9477430fb350889dc46cdf63dee17f9
2018-11-01 15:45:18 +05:30
Zuul 5393335ad7 Merge "Adding 'date' for trust_flush" 2018-10-23 17:23:41 +00:00
Vishakha Agarwal 7e42d333c7 Adding 'date' for trust_flush
This patch adds functionality to purge
expired and soft-deleted trusts older
than the given date.

Change-Id: I0bd47e57f8650182e38b4f70e04cb53338fce474
Related-Bug: #1473292
2018-10-23 15:13:15 +05:30
Vishakha Agarwal 48dcdb5ad3 Remove deprecated token_flush
This patch removes the deprecated token_flush
in stein release of openstack.

Change-Id: Ifc6d162923072d657fd5c163b94ffcd88dc80692
Implements: bp removed-as-of-stein
2018-10-17 14:44:26 +05:30
Zuul f4e052b8bf Merge "Purge soft-deleted trusts" 2018-10-04 06:20:17 +00:00
Vishakha Agarwal 6aba78a7a2 Purge soft-deleted trusts
This patch adds the functionality for purging both
expired trusts as well as non-expired soft-deleted
trusts, since those soft-deleted trusts are
as likely to bloat the database as expired trusts.

Related to patch-
https://review.openstack.org/#/c/589378/

Change-Id: I3c74f2345a944ce03a8189c4e66c3c37350cd34f
Related-Bug: #1473292
2018-10-02 09:49:53 +05:30
Vishakha Agarwal 94e6b28411 Adding test case for MappingEngineTester
Mapping Engine Tester is untested. Looking
at a coverage report for the Keystone CLI
shows missing test cases for MappingEngine
Tester. This patch adds the test cases and
also fixes the compatibility issues of
MappingEngine with python3.

Change-Id: Id0844ba1f4e2979d91414d3bc821ab25650c6935
Closes-Bug: #1782197
2018-09-27 16:22:30 +05:30
Zuul 50b2d6aa0e Merge "Implement Trust Flush via keystone-manage." 2018-09-24 17:06:32 +00:00
Vishakha Agarwal 8232dabcf9 Implement Trust Flush via keystone-manage.
Creates a cli entry 'trust_flush' which removes
all expired trusts.

Change-Id: I1c85b67d24e05db86c85e722fbd773a411c24ac4
Closes-Bug: #1473292
2018-09-18 13:51:11 +05:30
Lance Bragstad 254100128d Allow for more robust config checking with keystone-manage
Keystone was logging a warning saying "no configuration file was
found" when one was clearly passed to keystone-manage. This was
due to the fact that keystone-manage was really just checking for
default configuration file values. This means that users passing
a specific configuration file location to keystone-manage would
see a warning that wasn't necessarily true since keystone-manage
passes sys.argv to oslo.config, which resolves the argument
properly.

This change enhances the check to make sure keystone-manage isn't
dealing with a configuration file passed in from an end-user before
emitting the warning.

This change also cleans up some of the interactions between
keystone.cmd.manage and keystone.cmd.cli to make the variables
more clear about their purpose.

Change-Id: I6d58d9c499c447ef1cfd6edd4aeb1176130fb6ad
Closes-Bug: 1782704
2018-08-07 14:24:12 +00:00
Kristi Nikolla 83dc62ac90 Fix keystone-manage saml_idp_metadata under python3
metadata.to_string() was generating a bytes string, which python3
prepends with b'' when using the print function. Seems like
removing the to_string() call and just calling print on the object
makes it work correctly under both python3 and python2.

Change-Id: I546ba0b15f6196be7bbb5940e9f00434d5e6b1ff
Closes-Bug: #1780377
2018-07-06 00:25:54 -04:00
Zuul 426a6f2d95 Merge "Fix keystone-manage mapping_purge with --type option" 2018-06-29 07:59:00 +00:00
DaiHanada 74684cf53b Fix keystone-manage mapping_purge with --type option
"keystone-manage mapping_purge" has "--type" option in order to select
mappings which have to be deleted. However, the option doesn't work
and all mappings are purged when specifying this option.
The command passes a value of the option to purge_mappings API with
a key name "type", but the API expects "entity_type".

Change-Id: Ib222d70d4cf6bb61847cef049ec1ded5c2ff2c8b
Closes-Bug: #1757022
2018-06-26 19:15:38 +00:00
Zuul b106c70170 Merge "Ensure default roles created during bootstrap" 2018-06-15 11:50:47 +00:00
Harry Rybacki d44ed7f18c Ensure default roles created during bootstrap
Expand bootstrap process to include creation of roles outlined in
basic default roles spec.

The bootstrap process now creates two new roles, 'reader' and 'member,
in addition to the well established 'admin' role. During this process,
a role implication[1] chain is created: 'admin' implies 'member' and
'member' implies 'reader'.

[1] - https://developer.openstack.org/api-ref/identity/v3/#create-role-inference-rule

Co-Authored-By: Juan Antonio Osorio Robles <jaosorior@redhat.com>
bp basic-default-roles
Depends-On: https://review.openstack.org/574149
Change-Id: Ie18a269e3d1075d955fe494acaf634a393c6bd7b
2018-06-14 10:54:54 -04:00
Adrian Turjak 45d724f535 Revert "Rename fernet_utils to token_utils"
This reverts commit 03ba867327.

Because of the introduction of auth receipts we will be
using fernet for more than just tokens. Lets make this a
generic util for fernet key handling.

Change-Id: I3a870a63239491f84db3350178bd2313eeccdbf3
2018-06-06 16:49:27 +12:00
Lance Bragstad dd4b5e7efb Decouple bootstrap from cli module
We have a cli command that's useful for bootstrapping new
deployments, resetting administrator passwords, creating the default
domain, et cetera. But this functionality isn't just useful for
operators. We could actually benefit from using the same process
in our tests.

Many test cases actually do a bunch of their own setup. Sometimes
they duplicate a lot of what bootstrap already provides. Other times
test modules just blindly inherit from ``core.TestCase`` to get
things works. This isn't ideal because it isn't DRY. It also becomes
really easy to tack on extra cycles to each test when things are
added to the generic ``load_fixtures`` method that is typically run
for each test.

Instead, we can try and reuse what we give to operators for our
testing. This will:

  - Reduce duplicate setup scenarios across test modules
  - Reduce extra resource creation and cleanup when it's not needed
    for a particular set of test
  - Enforces better readability if each test case assumes the same
    basic structure of data present after bootstrap, test classes
    that need addition resources should include those in their
    setUp or setUpClass methods
  - We engrain the testing of a tool we provide to operators into
    our testing environment

This commit helps us move in that direction by encapsulating the
logic for bootstrapping deployments into a reusable object that is
accessible by both the tests and the cli tooling.

Change-Id: I84c75076405e6af9356f79778f2d2e67855f4fe0
2018-05-17 13:10:16 +00:00
Lance Bragstad 9ca374091b Log warning when using token_flush
The `keystone-manage token_flush` command was useful when we
supported token format that were actually written to disk. Now that
keystone has moved towards formats that don't require physical
storage in the name of scalability, we no longer need the
token_flush utility.

This commit logs a warning when using `keystone-manage token_flush`
so that people are aware they don't need to use it anymore if they
are using supported upstream non-persistent token providers.

Change-Id: I14d1e8a3ae367c8f13b6819a1a216f3f8f6b001a
Closes-Bug: 1759289
2018-03-29 20:15:55 +00:00
Gage Hugo deb91e2084 Add new setup commands for token keys
This change adds new token_setup and token_rotate commands that uses the
same functionality as fernet_setup and fernet_rotate. These commands are
to move users to a more generic use case.

Change-Id: I118f9a89d28d8ec1ccaf88a90053fa723ef98cff
2018-02-23 14:15:47 -06:00
Lance Bragstad 3c524e6491 Grant admin a role on the system during bootstrap
Now that we have system scope in place, we should make sure at least
one user has a role assignment on the system. We can do this at the
same time we grant the user a role on a project during bootstrap.

This is backwards compatible because even if a deployment doesn't use
system-scope, the assignment will just sit there. The deployment will
have to opt into enforcing scope by updating configuration options
for oslo.policy to enforce scoping.

This shouldn't prevent deployments from fixing bug 968696 and using
system scope.

Closes-Bug: 1749268

Change-Id: I6b7196a28867d9a699716c8fef2609d608a5b2a2
2018-02-13 21:37:31 +00:00
Zuul 54b0f9d126 Merge "Rename fernet_utils to token_utils" 2018-01-16 13:48:28 +00:00
wangxiyuan 23d14f5562 Deprecate member_role_id and member_role_name
``member_role_id`` and ``member_role_name`` config options
are only used for V2. Instead of removing, just deprecate
them because that maybe some consumers still use them
for V3.

This patch also removed the usage in
``keystone-manage bootstrap`` as well.

Closes-bug: #1728690

bp: deprecated-as-of-queens
bp: removed-as-of-queens

Change-Id: Ib85479442ec68f9a67615c23e5c39bd217c9b109
2017-12-18 09:15:54 +08:00
Gage Hugo 03ba867327 Rename fernet_utils to token_utils
This change renames the fernet_utils from keystone.common to
token_utils in order to provide more generic tools for the
implementation of alternative token providers.

Change-Id: I85091709ed4ed7bdd2c2d053e342e4b1b615ef08
2017-12-12 16:38:42 -06:00