diff --git a/keystoneclient/auth/base.py b/keystoneclient/auth/base.py index 4c743d9..ecbcf96 100644 --- a/keystoneclient/auth/base.py +++ b/keystoneclient/auth/base.py @@ -108,6 +108,36 @@ class BaseAuthPlugin(object): """ return False + def get_user_id(self, session, **kwargs): + """Return a unique user identifier of the plugin. + + Wherever possible the user id should be inferred from the token however + there are certain URLs and other places that require access to the + currently authenticated user id. + + :param session: A session object so the plugin can make HTTP calls. + :type session: keystoneclient.session.Session + + :returns: A user identifier or None if one is not available. + :rtype: str + """ + return None + + def get_project_id(self, session, **kwargs): + """Return the project id that we are authenticated to. + + Wherever possible the project id should be inferred from the token + however there are certain URLs and other places that require access to + the currently authenticated project id. + + :param session: A session object so the plugin can make HTTP calls. + :type session: keystoneclient.session.Session + + :returns: A project identifier or None if one is not available. + :rtype: str + """ + return None + @classmethod def get_options(cls): """Return the list of parameters associated with the auth plugin. diff --git a/keystoneclient/auth/identity/base.py b/keystoneclient/auth/identity/base.py index 94b0712..610039a 100644 --- a/keystoneclient/auth/identity/base.py +++ b/keystoneclient/auth/identity/base.py @@ -236,6 +236,12 @@ class BaseIdentityPlugin(base.BaseAuthPlugin): return url + def get_user_id(self, session, **kwargs): + return self.get_access(session).user_id + + def get_project_id(self, session, **kwargs): + return self.get_access(session).project_id + @utils.positional() def get_discovery(self, session, url, authenticated=None): """Return the discovery object for a URL.