Provide redirection for all security context attributes

The previous attempt at this was to redirect as little as possible.
However, this has proven to be problematic twice. auth_cacert wasn't
redirected, it was used by some of the OpenStack actions and thus
blocked Mistral [1] patch that would have Mistral start using the new
context.

This change redirects all properties in the SecurityContext which should
be safer for our internal actions and for end users actions.

[1]: https://review.openstack.org/#/c/506185/14

Partial-Bug: #1718353
Needed-By: Ife653558bfcda794e7f37086832f70b0ad7c28a4
Change-Id: I6057d0ce3fe4ae23468be8fb06cb85dc5f467f6b
(cherry picked from commit 817461b40c)
This commit is contained in:
Dougal Matthews 2017-11-09 08:58:50 +00:00
parent 90457d594a
commit 8986ce9529
2 changed files with 15 additions and 31 deletions

View File

@ -26,35 +26,17 @@ class ActionContext(object):
"release.", DeprecationWarning
)
@property
def auth_uri(self):
self._deprecation_warning("auth_uri")
return self.security.auth_uri
@property
def user_name(self):
self._deprecation_warning("user_name")
return self.security.user_name
@property
def auth_token(self):
self._deprecation_warning("auth_token")
return self.security.auth_token
@property
def project_name(self):
self._deprecation_warning("project_name")
return self.security.project_name
@property
def project_id(self):
self._deprecation_warning("project_id")
return self.security.project_id
@property
def insecure(self):
self._deprecation_warning("insecure")
return self.security.insecure
def __getattribute__(self, name):
deprecated = [
"auth_cacert", "auth_token", "auth_uri", "expires_at", "insecure",
"is_target", "is_trust_scoped", "project_id", "project_name",
"redelivered", "region_name", "service_catalog", "trust_id",
"user_name"
]
if name in deprecated:
self._deprecation_warning(name)
return getattr(self.security, name)
return super(ActionContext, self).__getattribute__(name)
class SecurityContext(object):

View File

@ -59,8 +59,10 @@ class TestActionsBase(tests_base.TestCase):
ctx = _fake_context()
deprecated_properties = [
"auth_uri", "user_name", "auth_token", "project_name",
"project_id", "insecure"
'auth_cacert', 'auth_token', 'auth_uri', 'expires_at',
'insecure', 'is_target', 'is_trust_scoped', 'project_id',
'project_name', 'redelivered', 'region_name', 'service_catalog',
'trust_id', 'user_name'
]
for deprecated in deprecated_properties: