base auth plugin docs

Change-Id: I9966cf4bb8c9e23517adeee4c061d23a8e71630a
This commit is contained in:
Terry Howe
2014-10-22 14:46:34 -06:00
parent ab9442a204
commit 4a76e5e02f
3 changed files with 42 additions and 19 deletions

View File

@@ -0,0 +1,9 @@
BaseAuthPlugin
==============
.. automodule:: openstack.auth.base
Connection Object
-----------------
.. autoclass:: openstack.auth.base.BaseAuthPlugin
:members:

View File

@@ -29,23 +29,9 @@ import sys
from examples import common from examples import common
from examples import transport from examples import transport
from openstack.auth import base
from openstack import connection from openstack import connection
class TestAuthenticator(base.BaseAuthPlugin):
def __init__(self, token, endpoint):
super(TestAuthenticator, self).__init__()
self.token = token
self.endpoint = endpoint
def get_token(self, transport, **kwargs):
return self.token
def get_endpoint(self, transport, service, **kwargs):
return self.endpoint
def make_authenticate(opts): def make_authenticate(opts):
args = { args = {
'auth_plugin': opts.auth_plugin, 'auth_plugin': opts.auth_plugin,

View File

@@ -10,6 +10,28 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
"""
The base class for an authenticator. A plugin must define the get_token,
get_endpoint, and get_versions methods. The simpliest example would be
something that is just given such as::
class SimpleAuthenticator(base.BaseAuthPlugin):
def __init__(self, token, endpoint, versions):
super(SimpleAuthenticator, self).__init__()
self.token = token
self.endpoint = endpoint
self.versions = versions
def get_token(self, transport, **kwargs):
return self.token
def get_endpoint(self, transport, service, **kwargs):
return self.endpoint
def get_versions(self, transport, service, **kwargs):
return self.versions
"""
import abc import abc
import six import six
@@ -17,7 +39,6 @@ import six
@six.add_metaclass(abc.ABCMeta) @six.add_metaclass(abc.ABCMeta)
class BaseAuthPlugin(object): class BaseAuthPlugin(object):
"""The basic structure of an authenticator."""
@abc.abstractmethod @abc.abstractmethod
def get_token(self, transport, **kwargs): def get_token(self, transport, **kwargs):
@@ -35,6 +56,7 @@ class BaseAuthPlugin(object):
:param transport: A transport object so the authenticator can make :param transport: A transport object so the authenticator can make
HTTP calls. HTTP calls.
:type transport: :class:`Transport <openstack.transport.Transport>`
:return string: A token to use. :return string: A token to use.
""" """
@@ -46,8 +68,11 @@ class BaseAuthPlugin(object):
authenticator should use best effort with the information available to authenticator should use best effort with the information available to
determine the endpoint. determine the endpoint.
:param Transport transport: Authenticator may need to make HTTP calls. :param transport: Authenticator may need to make HTTP calls.
:param ServiceFilter service: Filter to identify the desired service. :type transport: :class:`Transport <openstack.transport.Transport>`
:param service: Filter to identify the desired service.
:type service: :class:`ServiceFilter
<openstack.auth.service_filter.ServiceFilter>`
:returns string: The base URL that will be used to talk to the :returns string: The base URL that will be used to talk to the
required service or None if not available. required service or None if not available.
@@ -57,8 +82,11 @@ class BaseAuthPlugin(object):
def get_versions(self, transport, service, **kwargs): def get_versions(self, transport, service, **kwargs):
"""Return the valid versions for the given service. """Return the valid versions for the given service.
:param Transport transport: Authenticator may need to make HTTP calls. :param transport: Authenticator may need to make HTTP calls.
:param ServiceFilter service: Filter to identify the desired service. :type transport: :class:`Transport <openstack.transport.Transport>`
:param service: Filter to identify the desired service.
:type service: :class:`ServiceFilter
<openstack.auth.service_filter.ServiceFilter>`
:returns list: Returns list of versions that match the filter. :returns list: Returns list of versions that match the filter.
""" """