48 Commits

Author SHA1 Message Date
zhangyanxian
1572eb2862 Fix typo in access.py
TrivalFix

Change-Id: I44250004eb56b579c227874e4b08e358e8dd8712
2016-11-16 10:13:53 +00:00
George Tian
ea84ff9d37 Remove redundant variable declaration
Change-Id: Ifc80f889f82e9853132b8f91e63cc53cfc476ac6
2016-10-09 19:59:05 +08:00
Navid Pustchi
bca112c8ba Fixing D202 and D203 PEP257 violation.
Currently tox ignores D202 and D203.
D202: No blank lines allowed after function docstring.
D203: 1 blank required before class docstring.
This change removes D202 and D203 ignores in tox and fix violations.

Change-Id: I97ef88c9cfd56774e47f789cbbcf8ccfe85d7737
2016-05-04 19:45:30 +00:00
Navid Pustchi
20e23f3e0d Fix D400 PEP257 violation.
Currently tox ignores D400.
D400: First line should end with a period.
This change removes it and make keystoneclient docstrings compliant with it.

Change-Id: I29ecb4c58bb03c0b9a3be0b7a74d18fb06a350f2
2016-04-23 17:47:25 +00:00
Navid Pustchi
946e928b52 Fix D401 PEP257 violation.
Currently tox ignores D401.
401: First line should be in imperative mood.
This change removes it and make keystoneclient docstrings compliant with it.

Change-Id: If34ff12d18390b357342cf29f2d116dd3c86a44d
2016-04-23 06:25:20 +00:00
Christopher J Schaefer
dbf4f31646 Removing bandit.yaml in favor of defaults
Removing old configuration options for build-in defaults of latest
bandit functionality. Also, marking flagged items with _# nosec_
with a descriptive comment on why the code is acceptable as is.

Co-Authored-By: Christopher J Schaefer <cjschaef@us.ibm.com>
Co-Authored-By: Tom Cocozzello <tjcocozz@us.ibm.com>

Change-Id: I138ebd46a8be195177361a9c3306bb70423b639d
2016-04-19 10:35:00 -05:00
lin-hua-cheng
77ed0d4d0c Address hacking check H405
Previously, there were a string of commits to keystone that addresed ignored
hacking checks. This commit does the same for H405 in keystoneclient. This
also modifies our tox.ini so that we no longer ignore H405 violations.

Change-Id: I2af152e5425a0e9c82314039fdbb90d661c22680
Closes-Bug: 1482773
2016-01-13 13:03:51 -08:00
Brant Knudson
1a2ccb001b Proper deprecation for AccessInfo management_url property
AccessInfo's management_url parameter wasn't properly deprecated
since all it had was a comment in the code. Proper deprecation
requires use of warnings and documentation.

bp deprecations

Change-Id: I0ee07c5adc6a7c91f8b23b291eea76f4ae7b3b89
2015-07-24 11:05:05 -05:00
Brant Knudson
6d82f1f17c Proper deprecation for AccessInfo auth_url property
Properly deprecate accessing AccessInfo's auth_url parameter.

bp deprecations

Change-Id: I3824904f517434b507587cf73d4389b72f73f22b
2015-07-24 11:05:05 -05:00
Brant Knudson
f782ee853c Proper deprecation for AccessInfo scoped property
Properly deprecate constructing AccessInfo's scoped parameter.

bp deprecations

Change-Id: I8f81c75eb8e758feb9d4c62ce7f041957562e766
2015-07-24 09:14:40 -05:00
Brant Knudson
8d65259cb8 Proper deprecation for AccessInfo region_name parameter
Properly deprecate constructing AccessInfo with region_name
parameter.

bp deprecations

Change-Id: Ic5f48a4f5354beb8be68c2fd788bf0a974501917
2015-07-24 08:16:03 -05:00
Jamie Lennox
dfc90092a7 Expose audit_id via AccessInfo
The audit_id is now a standard part of the v2 and v3 tokens. Expose it
via AccessInfo so that it is usable for services and middleware.

Change-Id: I14ddcfee5434084ad9da73c384e6f456602fdd2b
Closes-Bug: #1437129
2015-03-28 14:33:15 +11:00
Brant Knudson
ab09d3eb5f Switch from oslo.utils to oslo_utils
oslo_utils moved out of the oslo namespace.

bp drop-namespace-packages

Change-Id: I72e67dc1f649ba137dd06f5ab7133858c6abd67d
2015-01-31 08:03:37 -06:00
Jenkins
41afe3c963 Merge "Docstring cleanup for return type" 2014-12-02 01:46:24 +00:00
Brant Knudson
fece74ca3e I18n
Keystoneclient didn't provide translated messages. With this
change, the messages are marked for translation.

DocImpact

Implements: blueprint keystoneclient-i18n

Change-Id: I85263a71671a1dffed524185266e6bb7ae559630
2014-10-28 20:33:19 +00:00
Jenkins
a417bf9e0a Merge "Use oslo.utils and oslo.serialization" 2014-10-16 00:14:18 +00:00
Brant Knudson
3f1ba9f007 Docstring cleanup for return type
The :returns: directive doesn't take an argument. To specify the
return type, use the :rtype: directive.

Change-Id: I3aaab824792333b3f75a10af92f5b712cc9b4ff6
2014-10-15 12:24:52 -05:00
Marek Denis
8b267842a7 Docstrings should have :returns: everywhere.
Some of the docstrings have ``:return:`` instead of ``:returns:``
keyword. This patch fixes that and make it consistent.

Change-Id: I4321a63798ab9e2abdf0bbd716bf2b995be22ba3
2014-10-15 13:34:19 +02:00
Steve Martinelli
802301ca17 Use oslo.utils and oslo.serialization
Left timeutils and strutils in openstack/common since they are used in
openstack/common/apiclient and memorycache.

Change-Id: Idb5f09c159d907dfba84cd1f7501f650318af7d9
2014-10-15 04:25:50 +00:00
Marek Denis
7006f9b008 Handle federated tokens
Federated tokens don't include domains in the user object.
Keystoneclient should be able to estimate whether the token is a
federated one and, if so, don't expect user domain information.
In case of the federated token keystoneclient returns None in response
to user_domain_name and user_domain_id calls.

Co-Authored-By: Steve Martinelli <stevemar@ca.ibm.com>

Closes-Bug: #1346820
Change-Id: I3453275fa1b0a41b1c015b0c3a92895a77d69a41
2014-09-17 15:46:49 -04:00
Jamie Lennox
0a0373142c Standardize AccessInfo token setting
When settings tokens via the factory v2 and v3 work completely
differently. This is somewhat expected due to tokens working differently
but it makes it hard to work with.

For example, if i have a v3 token but not the requests.Response that
created it there is no way for me to set the token data on the
AccessInfo object via factory.

Also in the case of V2 CMS tokens the value at ['token']['id'] is a fake
so that the signing process will work.

Allow overriding the token value from the factory and force setting the
token id on the AccessInfo in a standard way.

Change-Id: I856096dc5fae2ab0d1bedbac3294dc4976c3f3ad
2014-08-13 13:42:45 +10:00
Jamie Lennox
8c8fd65607 Add trust users to AccessInfo and fixture
A trust should always contain a trustee_user_id and a trustor_user_id.
Expose these values via AccessInfo if available.

Change-Id: Ic46a44300e6bf8aa694f1543d470c16fcac643fc
2014-06-29 23:17:46 +00:00
Jamie Lennox
3d29db1bd1 Add OAuth data to AccessInfo
Allow access to the access_token_id and the consumer_id that are set as
part of the Oauth authentication process.

This only makes sense for V3 tokens, as Oauth cannot be used with v2.

Change-Id: I9ac76f92acdfd6446a13f535b24e0a99f02f2eef
2014-06-30 09:17:04 +10:00
Jamie Lennox
588aaa3eaa Add issued handlers to auth_ref and fixtures
issued_at is a standard part of V2 and V3 tokens so add it to
AccessInfo in a similar way to expiry. Also it should be included when
generating tokens so include it in fixtures.

Change-Id: I0d62d8ce6472466886751e10e98046b8e398e079
2014-06-19 10:46:27 +10:00
Jamie Lennox
0aa9df3b76 Add role ids to the AccessInfo
Role Names are already there, add ids as well.

Change-Id: Ie6f14a60b182ec2f4ab97c6ced564e63a2f5169a
2014-06-19 10:46:07 +10:00
Jamie Lennox
d69461b18f Create a test token generator and use it
All the clients are currently storing samples of keystone tokens so that
they can use them in testing. This is bad as they are often out of date
or contain data that they shouldn't.

Create a V2 Token generator and make use of that for generating tokens
within our tests.

Change-Id: I72928692142c967d13391752ba57b3bdf7c1feab
blueprint: share-tokens
2014-04-03 11:20:33 +10:00
Jamie Lennox
a1278112ca Fix role_names call from V3 AccessInfo
This was probably initially written against an incorrect test token.

Change-Id: I3e1eb0cb207864dbadb01a477b180058902bb0cd
Closes-Bug: #1282410
2014-02-20 16:53:33 +10:00
Ilya Kharin
9ccc2029f9 Return role names by AccessInfo.role_names
A new method was introduced on AccessInfo class. The method role_names
returns a list of role names of a user associated to the authorization
request.

bp keystoneclient-auth-ref-get-roles

DocImpact

Change-Id: I0862aaaa27193119dc83ef38100c88b48a1d24a4
2014-01-28 11:58:06 +04:00
Jamie Lennox
d4c06d3035 Properly handle Regions in keystoneclient
Region name is taken as a parameter but is ignored in all communication
with the service catalog. Currently region can be stored in the token
data and then requests to url functions will return the appropriate
region. This is the wrong approach because there is nothing specific to
the token (or auth_data) that is region specific. Instead region
information should be held by the client.

Closes-Bug: 1147530
Closes-Bug: 1255992
Change-Id: I812aa89c8b4af28e294e63926a7f88e8246fffc5
2013-12-04 06:57:32 -06:00
Steven Hardy
5b7a460bc3 Allow v2 client authentication with trust_id
It should be possible to authenticate against the v2 tokens
API with a trust_id, because it suports rescoping an existing
token to a trust, this patch adds client support for this.

Note with the current keystone code it's necessary to pass the
trustor tenant ID when rescoping with a trust where
impersonation==True, e.g:

c = client_v2.Client(username=TRUSTEE_USERNAME,
                     password=TRUSTEE_USERNAME,
                     tenant_name=TRUSTEE_TENANT_NAME,
                     auth_url=OS_AUTH_URL_V2)
c.authenticate(trust_id=trust_i.id, tenant_id=TRUSTOR_TENANT_ID)

Change-Id: I177c41af298b7437e2c6fb437aa9ce9a09773b9d
Closes-Bug: #1231483
2013-09-26 15:33:00 +01:00
ZhiQiang Fan
893c87b662 Remove duplicate method in AccessInfo
Closes-Bug: #1217777

Method has_service_catalog is duplicate in AccessInfo, remove the
first one because this class is used as a base class.

Change-Id: Id5f6f0cfe223bd4f31b7c01a6bc1e750ad5a7cd8
2013-08-29 00:04:13 +08:00
Jamie Lennox
90d161fc3a Add domain attributes to accessinfo
user_domain_id and project_domain_id are already available, so simply
add an equivalent user_domain_name and project_domain_name if available.

The use of 'default' for v2 tokens is inspired from the default behaviour of
similar functions and what is used in auth_token middleware.

Change-Id: Ia9b345529072ab893d04c7a38fb7ba3acdc28227
2013-08-26 03:21:27 -07:00
Jamie Lennox
b43349a1ad Support older token formats for projects in accessinfo
Older token formats get decoded as a v2 token so we should support
reading project information from these tokens.

Change-Id: I31473a00b294bd0d7b535cfab8d2eaf09db97ff5
2013-08-26 03:20:23 -07:00
Steven Hardy
2c5ac69c8a Initial Trusts support
Implements client support for the basic trusts API operations,
note this does not include support for the roles subpath operations,
support for those can be added in a subsequent patch.

Change-Id: I0c6ba12bad5cc8f3f10697d2a3dcf4f3be8c7ece
blueprint: delegation-impersonation-support
2013-08-20 23:16:46 +01:00
Jenkins
fd8f05350b Merge "Use ServiceCatalog.factory, the object has no __init__" 2013-07-21 22:51:02 +00:00
Dirk Mueller
f2ad113d1c Fix and enable gating on H402
Docstring summaries need punctuation.

Change-Id: I1b740c13d5fedf9a625ca0807c908f651ee08406
2013-07-12 09:36:07 +02:00
Sascha Peilicke
a6312d52b7 Use ServiceCatalog.factory, the object has no __init__
Fixes LP bug #1199281

Change-Id: Iba4b3fd8ad2e6fe054ed705d8990c13dc5a13430
2013-07-09 11:09:08 +02: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
lin-hua-cheng
2239c3b27c Implements v3 auth client.
Added support for domain scoping.

Enhancement on AccessInfo to support reading v2/v3 token information.

Enhancement on ServiceCatalog for reading/filtering v2/v3 service
catalog information.

Change-Id: Ibb678b9933d3673e37d0fba857a152a3c5d2b4f4
2013-06-20 23:28:31 -07:00
Julien Danjou
a56ce5817f Use AuthRef for some client fields
This tackles some TODO items left over.

Change-Id: Ib062744acbf56f05d09857d244b78b35c0ef4d39
Signed-off-by: Julien Danjou <julien@danjou.info>
2013-06-11 10:00:13 +02:00
Dolph Mathews
abcf9db625 Fix line continuations (flake8 E125, E126)
- E125: continuation line does not distinguish itself from next logical
  line
- E126: continuation line over-indented for hanging indent

Change-Id: I626a6d5d57db927e8b239f90569b5601c772f28b
2013-06-03 08:04:07 -05:00
Jenkins
1cbda90717 Merge "Fix STALE_TOKEN_DURATION usage" 2013-01-26 17:32:13 +00:00
Jenkins
9392732a3f Merge "Factorize endpoint retrieval in access" 2013-01-24 22:16:12 +00:00
Julien Danjou
7afcea1e66 Fix STALE_TOKEN_DURATION usage
Change-Id: I9856684d93d8b45310e599863553a020180aa509
Signed-off-by: Julien Danjou <julien@danjou.info>
2013-01-24 18:48:22 +01:00
Julien Danjou
1f8a263fc4 Factorize endpoint retrieval in access
Change-Id: Iaace7020696b238e7829dbcae60f0bc7c74a79e4
Signed-off-by: Julien Danjou <julien@danjou.info>
2013-01-24 12:27:11 +01:00
Julien Danjou
ca348fe951 Remove useless code
- There's no need to call parent init function since that's the default
  behaviour.
- The token attribute is nor used nor updated anywhere.

Change-Id: Ib0b2729a396a2d761931ce0e178c49c49814eb21
Signed-off-by: Julien Danjou <julien@danjou.info>
2013-01-23 15:15:30 +01:00
Guang Yee
5939541bc7 bug-1040361: use keyring to store tokens
User can optionally turn off keyring by specifying the --no-cache option.
It can also be disabled with environment variable OS-NO-CACHE.

Change-Id: I8935260bf7fd6befa14798da9b4d02c81e65c417
2012-12-04 09:18:20 -08:00
Joe Heck
f1cc3cfc42 removing repeat attempt at authorization in client
blueprint solidify-python-api

* extended and updated documentation strings
* updated README.rst with latest options
* made debug a pass-through value, optionally set on client (instead of
  just being pulled from environment variable)
* adding AccessInfo object and associated tests
  (access.AccessInfo meant to be a cacheable object external to client
  and ultimately to replace service_catalog and it's existing functionality)
* extending authtoken to support lists of endpoints
* maintaining a single entity for client.management_url with first from
  list of possible endpoints
* create project_name and project_id synonyms to match tenant_name and
  tenant_id
* replacing authenticate call to a pure method, not overloading the
  resource/manager path that confuses base URL concepts.
* throw AuthorizationFailure if client attempts to access keystone
  resources before it has a management url
* special case listing tenant using auth_url for unscoped tokens authorized
  through client
* special case listing tokens.authenticate for Dashboard to allow unscoped
  tokens to hand back parity information to dashboard

Change-Id: I4bb3a1b6a5ce2c4b3fbcebeb59116286cac8b2e3
2012-11-09 00:02:41 +00:00