2382 Commits

Author SHA1 Message Date
Arun Kant
ce6336f393 User with creator role can delete his/her own secret and container
Modified policy and tests to verify this change.

As per this change, user with 'creator' role can delete a secret or
a container as long as that user has initially created that secret
or container.

There is still a difference between 'admin' role and 'creator' role
behavior around delete operation. With this change, users with 'creator'
role cannot delete any other user's secret/container in same project
while user with 'admin' role can do that.

Updated role docs to reflect this behavior.

Change-Id: I53e5529ed34ac4acc76348ca0431cb3de7934b6d
2016-07-25 13:42:01 -07:00
Jenkins
e994d4dd91 Merge "dogtag: Only call initialize() if crypto is not None" 2016-07-25 10:38:55 +00:00
Jenkins
31f1c80113 Merge "delete unused LOG" 2016-07-22 03:47:45 +00:00
Jenkins
fe41731a39 Merge "Updated from global requirements" 2016-07-20 00:48:46 +00:00
Douglas Mendizábal
55912386d5 Implement Date Filters for Secrets
This CR implements the spec for date filters.  The only difference
between the spec and this CR is the use of the alternative ISO format
(without the "Z") for specifying the dates.  This change was made to
have a more consistent API since the Zulu designation is not used
anywhere in the API where dates are shown to the user.  Additionaly the
libraries used for date-time parsing do not make use of the Zulu
designation either.

Implements: blueprint date-filters
DocImpact
APIImpact

Change-Id: Ic8fbe3d0e8b309bb192aaddf30291d1333756064
2016-07-19 09:27:49 -05:00
Thomas Bechtold
1d99f277ec dogtag: Only call initialize() if crypto is not None
_setup_nss_db_services() can return None in case the config option
[dogtag_plugin]nss_db_path is not set.
In that case, don't call the initialize() method which would fail with:

AttributeError: 'NoneType' object has no attribute 'initialize'

Change-Id: Ia6ffc8945d8125047273872ba75f0b084dc5810f
2016-07-19 16:25:31 +02:00
gecong1973
55e2cea1d5 delete unused LOG
remove unused LOG in crypto.py

Change-Id: I26a9dfb99e8c865865a6692d492a56ea078e2d25
2016-07-19 10:15:07 +08:00
OpenStack Proposal Bot
5ffbe2516a Updated from global requirements
Change-Id: I63fb950515d44b8eaf4b5c5269c857b72fd6e344
2016-07-18 18:07:27 +00:00
OpenStack Proposal Bot
d89e93b290 Imported Translations from Zanata
For more information about this automatic import see:
https://wiki.openstack.org/wiki/Translations/Infrastructure

Change-Id: I0bd2ffcc20ebd47bce9d1f2f75abac1c4b0e2fd4
2016-07-18 08:24:48 +00:00
Jenkins
2f2d718bb7 Merge "pkcs11-key-generation: convert mkek length to int" 2016-07-17 22:52:15 +00:00
Jenkins
e3ac69a008 Merge "Move rabbit configurations to oslo_messaging_rabbit section" 2016-07-12 06:40:49 +00:00
liujiong
45032b2b7d Move rabbit configurations to oslo_messaging_rabbit section
Configuration with oslo.messaging is listed in the DEFAULT section
in etc/barbican/barbican.conf.
According to this Change "I96a9682afe7eb0caf1fbf47bbb0291833aec245b"
of oslo.messaging, we now prefer to set them in "oslo_messaging_rabbit"
section.

Closes-Bug: #1590231
Change-Id: I2b952012b2192cfb95e28cf11f78cf56d6a414ca
2016-07-11 15:46:28 +08:00
Jenkins
6af3100944 Merge "Barbican tests fail because of incomplete test dependencies" 2016-07-10 20:31:56 +00:00
Jenkins
48bb77cf52 Merge "Correct reraising of exception" 2016-07-10 04:46:25 +00:00
Pan
22b22dcf58 Insecure default PROTOCOL_TLSv1 version in KMIP plugin
The default TLSv1 protocol version used by the KMIP plugin is insecure.
This can cause potential information disclosure by attacking connections
using vulnerable TLS protocols. This change will use TLSv1_2 if present.

Change-Id: I7018262cb74a95dfa24d6b94d49f1ebd62bdeebd
2016-07-07 18:13:07 -04:00
Bin Zhou
26fb788b47 Correct reraising of exception
when an exception was caught and rethrown, it should call 'raise'
without any arguments.

Change-Id: Ie7905e47e91547601ae78abf3a6e135a0f8ac2d6
2016-07-07 20:22:37 +08:00
liujiong
9df6e5bb7b Barbican tests fail because of incomplete test dependencies
Missing dependencies in test-requirements.txt

Closes-bug: #1428183
Change-Id: I894eb015cf9ceac7bbc315da81d300abd58cd7ef
2016-07-07 18:08:43 +08:00
Andreas Scheuring
50b4a1ae69 pkcs11-key-generation: convert mkek length to int
When specifying the mkek length via the cli, the key generation fails
as the length is being passed as string instead of int.

Co-Authored-By: Jan Stodt <stodtj@de.ibm.com>
Change-Id: If41d13bb4c99b8823642920d894900a9ce33294a
2016-06-29 10:01:55 +02:00
John McKenzie
592cf2ec28 Add support for modifying Generic Containers
This adds POST and DELETE support for a 'secrets' sub-resource on the
containers resource. This will allow a user to add or remove secret
references to an existing container. Only generic containers are
supported per the blueprint for this feature.

If a secret reference already exists in the container, an appropriate
error will be returned indicating that the secret already exists in
the container. I chose this approach over silently accepting the
update, as the name for the container secret could change, so a delete
and re-add seems to be the safer option if a user just wants to change
the name, which is not something that I see happening too often.
Additionally, the action is a POST and not a PUT, so it shouldn't
really update an existing resource.

APIImpact
Add support for POST and DELETE on container secrets sub-resources

DocImpact
Implements: blueprint api-containers-add-put

Change-Id: I6dfa6715385f421e4f173cf73c2b75b68da67051
2016-06-28 15:07:00 -05:00
OpenStack Proposal Bot
2088caf04b Updated from global requirements
Change-Id: I102aed6b534a4f881a4cc661e48c2bf9b9ee2ba9
2016-06-24 03:10:00 +00:00
Bertrand Lallau
cf0ffe7ca2 Remove unnecessary executable permissions
This removes executable permissions on modules not requiring it.

Change-Id: I497ed4ec1818515e63d76597a8d7670c49644262
2016-06-22 05:22:38 +00:00
Jenkins
9e36c95d07 Merge "Updated from global requirements" 2016-06-21 21:22:27 +00:00
OpenStack Proposal Bot
427706d6a1 Updated from global requirements
Change-Id: I6f46123b7499c1701c416b0e1a80a7bd732b4c08
2016-06-21 17:57:47 +00:00
Victor Stinner
c5012af5f2 Port last test (test_secrets) to Python 3
* normalize_before_encryption(): on Python 3, unencrypted is already a Unicode
  string (no need to decode).
* test_secrets: don't pass bytes string but native string (py2: bytes,
  py3: Unicode) as payload
* test_secrets: Decode HTTP bytes from UTF-8 for comparison
* test_get_secret_is_decoded_for_binary(): expect a binary string,
  not a Unicode string
* test_secrets: replace map() with a reglar loop (for) to execute
  child.delete() on Python 3. On Python 3, map() is now lazy and only
  execute the expression when the map is consumed.
* Remove tests-py3-blacklist.txt and the testenv:py34 section from
  tox.ini since all unit tests now pass on Python 3.4

Partially implements: blueprint barbican-py3
Change-Id: Ief8531c3b7201f884d5d4ca7a47a381d0bb9cb2c
2016-06-21 12:07:58 +02:00
Victor Stinner
b113f6364f Port test_quotas to Python 3
* test_quotas.py replace "params = {'bad data'}" (set) with "params =
  {'bad' :'data'}" (dict). On Python 2, webtest uses
  StringIO.StringIO() which accepts sets. On Python 3, webtest uses
  io.BytesIO() which doesn't accept sets.
* Remove following barbican.tests.api.controllers unit tests from
  tests-py3-blacklist.txt:

  - test_orders
  - test_quotas

Partially implements: blueprint barbican-py3
Change-Id: I58fc4e4274902a1196e466c00399fa2e8c4621ac
2016-06-21 12:07:58 +02:00
Victor Stinner
7a9c13f2e8 Port 3 more unit tests to Python 3
* barbican_manage.py: only decode bytes, not Unicode.
  six.string_types is str (Unicode) on Python 3.
* Replace long(1) with 1
* test_transport_keys_resource: decode HTTP body from UTF-8 to get
  Unicode.
* Replace ord(bytes[-1]) with ord(bytes[-1:]). On Python 3,
  bytes[int] returns an integer: use bytes[int:int] to get a
  substring.
* Remove following tests from tests-py3-blacklist.txt:

  - crypto.test_pkcs11
  - test_barbican_manage
  - test_transport_keys_resource

Partially implements: blueprint barbican-py3
Change-Id: I9189ac4106d05001ee0aee1299d100dd0d56bce0
2016-06-21 12:07:58 +02:00
Victor Stinner
c6342039cc Setup memory DB in test_cmd
Currently, test_cmd fails or not depending if
database_utils.setup_in_memory_db() was already called. It looks like
the test doesn't fail on Python 2, but it fails *sometimes* on
Python 3.

Maybe the tests are run in a diffrent order on Python 3 because of
the randomized hash function (it can be tried on Python 2 using -R
Python command line option).

The bug can been reproduced easily be running only test_cmd
on Python 2.7:

    $ . .tox/py27/bin/activate
    $ testr run barbican.tests.cmd.test_cmd
    ...
    FAIL: barbican.tests.cmd.test_cmd.WhenInvokingWorkerCommand.test_should_launch_service
    ...
    BarbicanException: No SQL connection configured

Change-Id: Ic68582193fa4a5002cab8333797eb3fe2881f051
2016-06-21 12:07:58 +02:00
Jenkins
873a2a5d94 Merge "Change SecretAcceptNotSupportedException from exception.BarbicanException to exception.BarbicanHTTPException" 2016-06-20 16:40:32 +00:00
Jenkins
502c1fff07 Merge "[Trivial] Remove executable privilege of doc/source/conf.py" 2016-06-16 09:25:57 +00:00
Jenkins
15507ea940 Merge "Correct a typo in apiary.apib" 2016-06-16 09:23:17 +00:00
liujiong
8bef6b47a5 Change SecretAcceptNotSupportedException from exception.BarbicanException to exception.BarbicanHTTPException
When retrieving secret's payload without providing payload_content_type,
if the payload_content_type is not default as "text/plain", we get 500 error.
Since this is generated by invalid input, we should mark this as 406 error.

Closes-bug: #1590097
Change-Id: I9ca94b7c66995991a9b0df37a46bd082e9795b74
2016-06-14 14:32:27 +08:00
Jenkins
6c9196621a Merge "Don't supply auth_token information by default in paste" 2016-06-13 03:43:36 +00:00
Ning Sun
0f7fbfc326 Correct a typo in apiary.apib
Change-Id: I76ce15a8a776b574c4e52f243297cf186fb0ad83
2016-06-10 14:56:19 +00:00
Jenkins
29e7356c9d Merge "Port API test_resources to Python 3" 2016-06-10 05:17:56 +00:00
Jenkins
1c2be9f686 Merge "Port test_validators to Python 3" 2016-06-10 05:17:45 +00:00
Jamie Lennox
700d16fa9e Don't supply auth_token information by default in paste
Auth_token middleware is expected to be configured by use of
oslo.config. Paste is really only mainted for swift. However paste
overrides the values provided in oslo.config so for anyone using
default barbican paste files and configuring auth_token middleware via
oslo.config they will have unexpected config overrides from the barbian
defaults.

Change-Id: I6bc49c4b62167410eaa70432f73abab2e829dc39
2016-06-09 09:57:43 +10:00
Cassandra Burnias
3d7600d9d4 Fixed typo in crypto plugin docs
This fixes a simple typo in the docs for the crypto plugin.

Change-Id: Ie50fe23fea189ac782602c8cb46ab72569e2a9ad
2016-06-08 15:30:17 -05:00
Bertrand Lallau
ea77fdca9b Remove unused oslo.concurrency requirement
Change-Id: I17fbd76f218b28030e604475fe7edd140e71831a
2016-06-06 09:35:27 +03:00
OpenStack Proposal Bot
4ccae1e5c3 Updated from global requirements
Change-Id: I796b82a7a18321aed82d4ebeb830cf4d866bd851
2016-06-04 12:47:18 +00:00
Jenkins
8f06bd7c41 Merge "Port snakeoil_ca to Python 3" 2016-06-04 05:00:34 +00:00
Jenkins
efb6e62e8e Merge "Do not count expired secrets toward quota" 2016-06-03 19:16:14 +00:00
John McKenzie
49becafc0d Do not count expired secrets toward quota
We should not count secrets that are expired when retrieving Secrets associated
with a given project.

Change-Id: I3a6e82ad60f484bac8046e7563270804ff665450
Closes-Bug: 1582872
2016-05-31 14:21:50 -05:00
OpenStack Proposal Bot
261b504052 Updated from global requirements
Change-Id: I5da3dd075f97b9a60e59e8419b21d5a5653954fd
2016-05-31 02:59:08 +00:00
Jenkins
ceec5bcd30 Merge "Add retry for recoverable PKCS11 errors" 2016-05-27 17:04:39 +00:00
John McKenzie
88aac6e6f1 Add retry for recoverable PKCS11 errors
When using the p11_crypto module with an HSM, certain errors can be thrown by
the device that currently require the Barbican application to be restarted to
recover. This CR adds to work already done to the pkcs11 module that will trap
known errors and will raise a specific exception that can be handled gracefully
without the need to restart the entire application.

In addition, the p11_crypto module has been enhanced to use a retry mechanism
when these known errors are raised after reinitializing the pkcs11 library.
This was done specifically to trap the CKR_TOKEN_NOT_PRESENT error from an HSM,
but can be enhanced further in the future to handle additional error conditions
that are recoverable with a simple reinitialization of the library to prevent
the need to restart the entire Barbican application.

Change-Id: Ic43f3729bff00560d4a344f785416546c019e016
Closes-Bug: 1582884
2016-05-26 11:20:05 -05:00
Victor Stinner
09ba305b36 Port API test_resources to Python 3
* _do_enforce_content_types(): only decode content type if it's a
  byte string (don't decode on Python 3)
* Decode bytes HTTP body to compare it to text string. On Python 3,
  bytes == str is always false (or emit/raise a BytesWarning).
* Use byte strings rather than text strings for literal HTTP body:
  HTTP body type is bytes.
* Remove test_resources from tests-py3-blacklist.py to run it

Partially implements: blueprint barbican-py3
Change-Id: I6d830ea620ac5a237b5e2929077eb2f4504b5e59
2016-05-26 16:11:04 +02:00
Victor Stinner
a0ca5c0e5e Port test_validators to Python 3
* Replace base64.b64encode() with
  oslo_serialization.base64.encode_as_text() which accepts bytes and
  text strings but only outputs text string.
* Use a text string for the JSON payload
* Remove test_validators from tests-py3-blacklist to run it

Partially implements: blueprint barbican-py3
Change-Id: Id97104ca9fb0d2acd6e72e6254ca985237e27859
2016-05-26 16:11:04 +02:00
Victor Stinner
fbe084db09 Port snakeoil_ca to Python 3
* Open files in binary mode: "rb" or "wb" mode
* Replace bytes.decode('base64') with base64.b64decode(bytes)
* Remove test_snakeoil_ca from tests-py3-blacklist.txt to run it

Partially implements: blueprint barbican-py3
Change-Id: Ib4ec41c280bf48e6c425b0a6161d2591997f0d28
2016-05-26 16:11:00 +02:00
OpenStack Proposal Bot
0326a260f4 Updated from global requirements
Change-Id: I26e5437b5d72289f19942f9a0911774bd0a39fe7
2016-05-23 20:42:17 +00:00
Jenkins
255de95011 Merge "Checking for input secret_ref to start with input request hostname" 2016-05-23 17:50:06 +00:00