Invalid parameter name on interface

There are several classes that inherit from the abstract method
AuthMethodHandler.authenticate. In some cases those classes are
not using matching parameter names.

This patch changes all classes such that the signatures match.
Prior to this there were four different signatures:

authenticate(self, context, auth_payload, auth_context)
authenticate(self, request, auth_info, auth_context)
authenticate(self, request, auth_payload, auth_context)
authenticate(self, request, auth_payload, user_context)

The new common signature will be:

authenticate(self, request, auth_payload, auth_context)

Change-Id: I2846af0528dbb638436fdd0731d99c6a627608d7
This commit is contained in:
Eric Brown 2016-11-19 09:16:22 -08:00
parent 85ef776abb
commit 872939d8ee
5 changed files with 29 additions and 9 deletions

View File

@ -27,16 +27,19 @@ class AuthMethodHandler(object):
pass
@abc.abstractmethod
def authenticate(self, context, auth_payload, auth_context):
def authenticate(self, request, auth_payload, auth_context):
"""Authenticate user and return an authentication context.
:param context: keystone's request context
:param auth_payload: the content of the authentication for a given
method
:param request: context of an authentication request
:type request: common.request.Request
:param auth_payload: the payload content of the authentication request
for a given method
:type auth_payload: dict
:param auth_context: user authentication context, a dictionary shared
by all plugins. It contains "method_names" and
"extras" by default. "method_names" is a list and
"extras" is a dictionary.
:type auth_context: oslo_context.RequestContext
If successful, plugin must set ``user_id`` in ``auth_context``.
``method_name`` is used to convey any additional authentication methods

View File

@ -30,7 +30,7 @@ CONF = keystone.conf.CONF
@six.add_metaclass(abc.ABCMeta)
class Base(base.AuthMethodHandler):
def authenticate(self, request, auth_info, auth_context):
def authenticate(self, request, auth_payload, auth_context):
"""Use REMOTE_USER to look up the user in the identity backend.
auth_context is an in-out variable that will be updated with the

View File

@ -25,7 +25,7 @@ from keystone.oauth1 import validator
@dependency.requires('oauth_api')
class OAuth(base.AuthMethodHandler):
def authenticate(self, request, auth_info, auth_context):
def authenticate(self, request, auth_payload, auth_context):
"""Turn a signed request with an access key into a keystone token."""
oauth_headers = oauth.get_oauth_headers(request.headers)
access_token_id = oauth_headers.get('oauth_token')

View File

@ -39,17 +39,17 @@ class Token(base.AuthMethodHandler):
return token_model.KeystoneToken(token_id=token_id,
token_data=response)
def authenticate(self, request, auth_payload, user_context):
def authenticate(self, request, auth_payload, auth_context):
if 'id' not in auth_payload:
raise exception.ValidationError(attribute='id',
target='token')
token_ref = self._get_token_ref(auth_payload)
if token_ref.is_federated_user and self.federation_api:
mapped.handle_scoped_token(
request, user_context, token_ref,
request, auth_context, token_ref,
self.federation_api, self.identity_api)
else:
token_authenticate(request, user_context, token_ref)
token_authenticate(request, auth_context, token_ref)
def token_authenticate(request, user_context, token_ref):

View File

@ -0,0 +1,17 @@
---
other:
- >
The signature on the ``authenticate`` method of
``keystone.auth.plugins.base.AuthMethodHandler`` has been updated.
Third-party extensions that extend the abstract class
(``AuthMethodHandler``) should update their code according to the new
parameter names.
The method signature has changed from::
authenticate(self, context, auth_payload, auth_context)
to::
authenticate(self, request, auth_payload, auth_context)