22 Commits

Author SHA1 Message Date
Adam Young
7e1700c565 replace double quotes with single.
Change-Id: Ib2c828525fe3bafac8ed2f402a477ba62bbf6471
2014-04-21 16:55:20 -04:00
mathrock
bc12305ca1 Fix typo of ANS1 to ASN1
Replace all occurrences of 'ANS1|ans1' with 'ASN1|asn1'.  Keep
cms.is_ans1_token() around for backwards compatibility.

Change-Id: I89da78b89aa9daf2637754dc93031d7ca81e85cb
Closes-bug: 1306874
2014-04-14 22:22:30 -04:00
Brant Knudson
82359492dc Hash functions support different hash algorithms
The token hash functions always used MD5. With this change, the
hash function can be passed in to the hash functions.

SecurityImpact
Related-Bug: #1174499

Change-Id: Ia08c2d6252bb034087a244b47d5bcbea7dcfa70b
2014-04-09 13:54:30 -05:00
Brant Knudson
8281f7531f Fix doc build errors
There were some parts that had invalid RST in their docstrings
which caused warnings and errors to be generated.

Related-Bug: #1278662
Change-Id: Ibb53e6f49b5fa100fa6ecfe47331f9a70729d03b
2014-03-13 19:35:54 -05:00
Jenkins
ef69e08078 Merge "Remove vim header" 2014-02-13 03:43:31 +00:00
Jenkins
b34bb1b02b Merge "cms: Use universal_newlines=True in subprocess.Popen()" 2014-02-10 02:25:11 +00:00
Eric Guo
d6d0d66374 Remove vim header
We don't need vim modelines in each source file, it can be set in
user's vimrc.

Change-Id: Ic7a61430a0a320ce6b0c4518d9f5d988e35f8aae
Closes-Bug: #1229324
2014-02-08 22:22:08 +08:00
Cyril Roelandt
1ee161e162 cms: Use universal_newlines=True in subprocess.Popen()
The Python documentation states that "the type of [the first argument of
subprocess.communicate()] must be bytes or, if universal_newlines was True, a
string"[1]. Currently, in Python 3, a text string is given to
subprocess.communicate(), even though the process was created with
universal_newlines=False (the default value).

Rather than converting strings to bytes (and the other way around) everywhere
in the code, just create the process with universal_newlines=True. The side
effect is that '\n', '\r\n' and '\r' will be recognized as ending lines[2],
which should not be an issue.

[1] http://docs.python.org/3/library/subprocess.html?highlight=popen#subprocess.Popen.communicate
[2] http://docs.python.org/3/glossary.html#term-universal-newlines

Change-Id: I668b187ba8ed00ad6d55ec487af623b79b21589d
2014-02-07 04:31:25 +01:00
Jenkins
bb7f6aa9a9 Merge "Check for any monkeypatching" 2014-02-06 23:04:17 +00:00
Adam Young
9dc231999b Check for any monkeypatching
Checking oinly for monkeypatching of the ``os`` module is
insufficient.  A process might have chosen not to patch ``os`` but
still needs to use the eventlet version of Popen to deal with proper
forks.  This version checks if any modules have been monkeypatched
with the eventlet versions.

Closes-Bug: #1277231

Change-Id: Ia8d7150e9e7ced58132e8e90e7ad68fb3c7c3b9f
2014-02-06 14:29:23 -05:00
Cyril Roelandt
6f28bdabe9 Python 3: make tests from v2_0/test_access.py pass
This fixes calls to the hash_signed_token() and cms_hash_token() functions, by
making sure they are given bytes.

Change-Id: I83ac48a845cd09150b01afad6f0549ee83c20ddd
2014-02-04 21:51:04 +01:00
Dirk Mueller
07a7c3102c Add workaround for OSError raised by Popen.communicate()
Python 2.6 can raise OSError when too much data is
written to STDIN and the process died prematurely.

In the case of keystoneclient this happens during
the first cms_verify() call of a process. The calling
logic expects a useful error message in order to
refetch the CA or singing CERT, which is missing in the
case of an OSError. So just fake it instead.

Add basic unit tests to cover all of the public methods from
keystone.common.cms, raising test coverage to 77%. Add
unit test for this specific bug (test_cms_verify_token_no_oserror).

Closes-Bug: LP Bug#1235252

Change-Id: I6e650ab9494c605b4e41c78c87a9505e09d5fc29
2013-11-28 22:53:43 +01:00
Lei Zhang
0c8faa3efc Migrate the keystone.common.cms to keystoneclient
- Add checking the openssl return code 2, related to following review

  https://review.openstack.org/#/c/22716/

- Add support set subprocess to the cms, when we already know which
  subprocess to use.

Closes-Bug: #1142574
Change-Id: I3f86e6ca8bb7738f57051ce7f0f5662b20e7a22b
2013-10-28 23:35:56 +08:00
Morgan Fainberg
35deb1ae1b Fix License Headers and Enable Gating on H102
Add ASLv2 headers to files that were missing it.

fixes bug #1211587

Change-Id: Iede918e1ce84993cee4ecbb2d9c2606627fa412e
2013-08-27 00:04:03 -07:00
Adam Young
2bb6137f48 no logging on cms failure
Don't log in the keystoneclient.common.cms as there are some errors
that are expected.  Instead, log in the middleware

bug 1189539

Change-Id: I1e80e2ab35e073d9b8d25fd16b31c64c34cd001d
2013-07-26 20:45:47 -04:00
Dirk Mueller
c555662b20 Merge " Cleanup docstrings " from keystone/common/cms.py
In an attempt to unify both implementations in order to
be able to remove one of the duplicated ones, merge the
changes from this commit in keystone:

    Author: Dolph Mathews <dolph.mathews@gmail.com>
    Date:   Fri May 24 11:36:44 2013 -0500

    Cleanup docstrings (flake8 H401, H402, H403, H404)

Change-Id: Ib23c9ab5066cfdcdda4e07cd30fa8f6ff47949bd
2013-07-09 18:29:56 +02:00
Jenkins
6d0afcc98e Merge "Log cms_verify issues as warnings (not errors)." 2013-07-09 07:58:28 +00:00
Dirk Mueller
fe8f9023ac Fix and enable H401
Remove leading spaces from doc comments.

Change-Id: I75b055c0d64dda478c63839d44158e301900107f
2013-06-27 01:28:30 +02:00
Dan Prince
a4af27a705 Log cms_verify issues as warnings (not errors).
In general we probably do want to log these types of errors... but
not as ERRORS. I think log Warning messages are probably more
appropriate here since it would be possible to hit this when
expired certs are refreshed...

Fixes LP Bug #1190230.

Change-Id: I0383f7e490ddcdfb31a62cd3760102152a8d16d9
2013-06-12 09:21:10 -04:00
Dolph Mathews
6f27af4a0c Fix unused imports(flake8 F401, F999)
- F401: imported but unused
- F999: syntax error in doctest

Fixing a couple of the F401's simply required fixing the doctests syntax
where the imports were actually in use.

Change-Id: If78abbb143daf8d005a71c5ab52836df29c5e0cd
2013-06-03 13:05:12 +00:00
Dirk Mueller
05f731253d Restore Python 2.6 compatibility
Python 2.6 did not have a keyword argument 'output'
in the constructor defined yet, which caused a TypeError
exception

Change-Id: I4d455bef3480a7511172c58fd4794fa1e8acce8c
2013-01-22 09:52:51 +01:00
Henry Nash
7920899af1 Add auth-token code to keystoneclient, along with supporting files
This step in the process duplicates the auth-token code to keystoneclient but,
for the moment, leaves a copy in its origional location in keystone.
Testing for auth-token is also copied across, as is the cms support file.

Although no other project will yet pick up the code here in the client, since
the paste.ini files haev not yet been updated, it would work if anyone
did reference it.

Once the client code is in, the next step is to update all the other
project paste files, and then finally retire the code from keystone.

Change-Id: I88853a373d406020d54b61cba5a5e887380e3b3e
2012-11-12 19:40:21 +00:00