Currently the MockKeyManager raises KeyError when a key is not found
for a get() or delete() but a real key manager raises
ManagedObjectNotFoundError in the case of not found [1][2].
This updates the MockKeyManager to raise the same exception as a real
key manager so that projects using it in tests will be able to test
their handling of "not found" scenarios properly.
[1] a662b30764/castellan/key_manager/barbican_key_manager.py (L617)
[2] a662b30764/castellan/key_manager/barbican_key_manager.py (L644)
Change-Id: I3184a229f6690854dda1edc12e74bb483b47a057
This change adds the force parameter to the secret delete
method. By default, a secret cannot be deleted if it
contains consumers.
This code cannot be merged without a corresponding release and
bump of version for the barbicanclient.
Co-Authored-By: Mauricio Harley <mharley@redhat.com>
Change-Id: I84fd870b1cd19975a5bb832ed6fd6d18ec56eb5a
This change adds the ability to add or remove consumers to a
managed object to allow services to indicate which object is
associated with a specific secret. At this time, only barbican
supports consumers.
This code cannot be merged without a corresponding release and
bump of version for the barbicanclient.
Co-Authored-By: Mauricio Harley <mharley@redhat.com>
Depends-On: https://review.opendev.org/c/openstack/requirements/+/873906
Change-Id: Ic25ac329f87db5992e32ef0b2d7d4020f37b2dee
This adds consumers to the objects. Unit tests are
also covered.
Co-Authored-By: Ade Lee <alee@redhat.com>
Co-Authored-By: Mauricio Harley <mharley@redhat.com>
Change-Id: I598209e30d8f0e4515292b1f8c9a89aa952bac4e
This commit adds support for a Vault path that is relative to
the root of the Vault KV store. This configuration is optional
and will be a noop for existing deployments.
Change-Id: If34c38c8f0a2f13ea90f564bfe5e933e5e748da4
Tests periodically fail right now because the cleanup which is
running in a different thread sometimes removes the managed objects
before we have completed testing with them. The change to use
concurrency=1 will slow down the tests, but also make them more
consistent.
Also, when things are not cleaned up, you can get false positive
results if multiple objects contain the same content. This will
fix this problem by making the contents unique.
Change-Id: Ic2b9e6afe9371dbe135e90fa6df36a8e91921556
The target value is exactly same as the default defined in oslo.log,
thus this override is just redundant.
Change-Id: I91fcc035526d655f0b885f5b6a176dc18577a3a3
Vault Namespaces [0] is a feature available in Vault Enterprise that
can be considered as a more advanced isolation feature on top of current
KV Mountpoint option in Castellan Vault plugin.
Passing a namespace in all request headers (including Auth) allows to organize
Vault-in-Vault style of isolation, with clients using the same simple URI path
but accessing separate sets of entities in Vault.
[0] https://www.vaultproject.io/docs/enterprise/namespaces
Change-Id: I627c20002bb2a0a1b346b57e824f87f856eca4c9
This change adds support to the Barbican key manager for configuring a
service user. This can be used to provide additional security through
the combination of a user token and a service token, with appropriate
modifications to Barbican API policy.
Use of a service user is enabled via the [barbican]
send_service_user_token option, which defaults to False. When set to
True, the service user is configured via keystoneauth options in the
barbican_service_user group.
Change-Id: I143cb57c8534a8dc0a91e6e42917dd0c134170c0
This change introduces a new option to define the region to which
the Barbican endpoint belongs. This is required if the deployment has
multiple regions and a single Keystone instance stores multiple
Barbican endpoints for different regions.
This change also ensures that the same interface and region are used
in endpoint detection and api version detection.
Change-Id: If2c0055d45922937e259a8f22f5879c9faa41e35
It is standard practice to search for services in the catalog by
service type and interface only. Service name should be left
to deployers to choose and this could be something other than barbican.
Change-Id: I9dddba1e52bbf1ee1d8227fdb45e625fdbf0a21b
_get_barbican_endpoint now uses barbican_endpoint_type config option to
retrieve a correct endpoint from catalog.
This config option is set to 'public' by default and it's a default
value for ServiceCatalog.endpoint_data_for method. It means that the
default behaviour will be the same as before this patch.
Change-Id: Idf4061fe3e35e3c47a993a56b23c0257c92e5cc3
This patch centralizes the managed objects conversion in order to be
used across multiple key_manager backends.
Change-Id: Ia2e15d46eb2e504b815a7f51173aecaf82978402
Signed-off-by: Moisés Guimarães de Medeiros <moguimar@redhat.com>
This patch fixes the issue when guessing the KV API version fails.
From now on, a configuration option should be used to set vault's API
version.
Change-Id: I962b29519c189dddf9723689e6aaeed2cac3ff2c
Signed-off-by: Moisés Guimarães de Medeiros <moguimar@redhat.com>
Vault returns Bad Request error if invalid secret ID is provided. It's
better to have such errors handled instad of generic "KeyError: 'auth'"
execption.
Change-Id: Ibc068af70de4022f544d394ec4b014443a9c16b5
Now we cann't use the verify_ssl if we set True, so we
add the "verify_ssl_path" config to solve it.
Closes-Bug: #1876102
Change-Id: I83bafe5b7e0c4cca67f773858007fb59d98a93a5
Now that we no longer support py27, we can use the standard library
unittest.mock module instead of the third party mock lib.
Change-Id: Ib3028d55552ef51d93aaf38653bca888166e6d27
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
The repo is Python 3 now, so update hacking to version 3.0 which
supports Python 3.
Fix problems found by updated hacking version.
Change-Id: I4f24c0fa5178f15912db899fcf26ca11480eab21
The Vault backend doesn't really care about context. Even an empty
string would suffice these checks.
Change-Id: I1c0d00675a479cf05d92cec7b69fd720a88023d3
Signed-off-by: Moisés Guimarães de Medeiros <moguimar@redhat.com>
Both Barbican and Vault backends have this replicated code. Let's
centralize it to reduce code duplication.
Change-Id: I365a6d3031695ee369664c00a61816c77792f2e2
Signed-off-by: Moisés Guimarães de Medeiros <moguimar@redhat.com>
nit: Certificate inherits from ManagedObject which already has
ABCMeta as metaclass.
Change-Id: I17b12980b88e306fbdc99a3e92b1fa22d8e96471
Signed-off-by: Moisés Guimarães de Medeiros <moguimar@redhat.com>
The KeyManager itself should be responsible for advertising the
correct set of options for discovery, not relying on the global
option listing method to know which variable holds the options
and how are they grouped.
Change-Id: I1764c383206df835b7d654f2f776663bd6d4d25b
Signed-off-by: Moisés Guimarães de Medeiros <moguimar@redhat.com>
When castellan trying to recreate trust-scoped token
from RequestContext keystone throw exception
because it's not allowed.
Starting from this commit castellan trying to
reuse existing token constructed from RequestContext
if get_auth_plugin() is available.
Change-Id: I10a12b9a2a7f796eca37dd20a280d3a4015a6903
Closes-Bug: #1827047
Depends-On: https://review.opendev.org/#/c/664558/
Previous code was considering length as bytes, but the API contract
considers the length param to be bits so that the considering `km`
as a VaultKeyManager, the call `km.create_key(ctx, 'AES', 256)` should
generate a 256 bit AES key and not a 2048 bit AES key instead.
Closes-Bug: #1817248
Change-Id: I5815cb74394e18b6058f4c5cf69b656d7cc2c43b
Signed-off-by: Moisés Guimarães de Medeiros <moguimar@redhat.com>
This driver is an oslo.config backend driver implemented with
Castellan. It extends oslo.config's capabilities by enabling it
to retrieve configuration values from a secret manager behind
Castellan.
Change-Id: Id7cf99bea5788e0a6309461a75eaa8d08d29641b
Signed-off-by: Moises Guimaraes de Medeiros <moguimar@redhat.com>
Support end user configuration of KV store in Vault to use for
key storage allowing more flexibility in Vault configuration.
Change-Id: I625a819c2b9b542677258de709a9c520fb86858b
Closes-Bug: 1797148
Add support for use of AppRole's for authentication to Vault; this
feature provides a more application centric approach to managing
long term access to Vault.
The functional tests exercise this integration with a restricted
policy which only allows access to the default 'secret' backend.
Change-Id: I59dfe31adb72712c53d49f66d9ac894e43e8bbad
Closes-Bug: 1796851
The new method handles the HTTP request for the Vault HTTP API
and does the error checking in a single place. The same code
was already in four different places in the same file.
Change-Id: I4b688d8cf994fb26f88570840523fcc0ac24faba
Signed-off-by: Moises Guimaraes de Medeiros <moguimar@redhat.com>
Starting from version 0.10.0, HashiCorp Vault has a different
API for the Key/Value Secrets Engine. This fix implements both
the new API support and the fallback for the legacy one.
Fixes https://bugs.launchpad.net/castellan/+bug/1788375
Change-Id: I7fed7b5091440dae15551d83f0ee0895651e47bf
Signed-off-by: Moises Guimaraes de Medeiros <moguimar@redhat.com>