# keystoneauth1.service_token module

class keystoneauth1.service_token.ServiceTokenAuthWrapper(user_auth: BaseAuthPlugin, service_auth: BaseAuthPlugin)

  Bases: `BaseAuthPlugin`

  __annotate_func__ = None
  __annotations_cache__ = {'_discovery_cache': 'dict[str, discover.Discover]'}
  __doc__ = None
  __firstlineno__ = 25
  __init__(user_auth: BaseAuthPlugin, service_auth: BaseAuthPlugin)
  __module__ = 'keystoneauth1.service_token'
  __static_attributes__ = ('service_auth', 'user_auth')
  get_connection_params(session: ks_session.Session) → ConnectionParams

    Return any additional connection parameters required for the plugin.

    Parameters:

      session (keystoneauth1.session.Session) – The session object that the auth_plugin belongs to.

    Returns:

      Parameters that are passed to the requests library. Only the `cert` and `verify` parameters may be returned.

    Return type:

      dict

  get_endpoint(session: ks_session.Session, **kwargs: Any) → str | None

    Return an endpoint for the client.

    There are no required keyword arguments to `get_endpoint` as a plugin implementation should use best effort with the information available to determine the endpoint. However there are certain standard options that will be generated by the clients and should be used by plugins:

    - `service_type`: what sort of service is required.

    - `service_name`: the name of the service in the catalog.

    - `interface`: what visibility the endpoint should have.

    - `region_name`: the region the endpoint exists in.

    Parameters:

      - session (keystoneauth1.session.Session) – The session object that the auth_plugin belongs to.

      - kwargs – Ignored.

    Returns:

      The base URL that will be used to talk to the required service or None if not available.

    Return type:

      string

  get_headers(session: ks_session.Session) → dict[str, str] | None

    Fetch authentication headers for message.

    This is a more generalized replacement of the older get_token to allow plugins to specify different or additional authentication headers to the OpenStack standard ‘X-Auth-Token’ header.

    How the authentication headers are obtained is up to the plugin. If the headers are still valid they may be re-used, retrieved from cache or the plugin may invoke an authentication request against a server.

    The default implementation of get_headers calls the get_token method to enable older style plugins to continue functioning unchanged. Subclasses should feel free to completely override this function to provide the headers that they want.

    Returning None will indicate that no token was able to be retrieved and that authorization was a failure. Adding no authentication data can be achieved by returning an empty dictionary.

    Parameters:

      session (keystoneauth1.session.Session) – The session object that the auth_plugin belongs to.

    Returns:

      Headers that are set to authenticate a message or None for failure. Note that when checking this value that the empty dict is a valid, non-failure response.

    Return type:

      dict

  get_project_id(session: ks_session.Session) → str | None

    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.

    Parameters:

      session (keystoneauth1.session.Session) – A session object so the plugin can make HTTP calls.

    Returns:

      A project identifier or None if one is not available.

    Return type:

      str

  get_sp_auth_url(session: ks_session.Session, sp_id: str) → str | None

    Return auth_url from the Service Provider object.

    This url is used for obtaining unscoped federated token from remote cloud.

    Parameters:

      sp_id (string) – ID of the Service Provider to be queried.

    Returns:

      A Service Provider auth_url or None if one is not available.

    Return type:

      str

  get_sp_url(session: ks_session.Session, sp_id: str) → str | None

    Return sp_url from the Service Provider object.

    This url is used for passing SAML2 assertion to the remote cloud.

    Parameters:

      sp_id (str) – ID of the Service Provider to be queried.

    Returns:

      A Service Provider sp_url or None if one is not available.

    Return type:

      str

  get_token(session: ks_session.Session) → str | None

    Obtain a token.

    How the token is obtained is up to the plugin. If it is still valid it may be re-used, retrieved from cache or invoke an authentication request against a server.

    Returning None will indicate that no token was able to be retrieved.

    This function is misplaced as it should only be required for auth plugins that use the ‘X-Auth-Token’ header. However due to the way plugins evolved this method is required and often called to trigger an authentication request on a new plugin.

    When implementing a new plugin it is advised that you implement this method, however if you don’t require the ‘X-Auth-Token’ header override the get_headers method instead.

    Parameters:

      session (keystoneauth1.session.Session) – A session object so the plugin can make HTTP calls.

    Returns:

      A token to use.

    Return type:

      string

  get_user_id(session: ks_session.Session) → str | None

    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.

    Parameters:

      session (keystoneauth1.session.Session) – A session object so the plugin can make HTTP calls.

    Returns:

      A user identifier or None if one is not available.

    Return type:

      str

  invalidate() → bool

    Invalidate the current authentication data.

    This should result in fetching a new token on next call.

    A plugin may be invalidated if an Unauthorized HTTP response is returned to indicate that the token may have been revoked or is otherwise now invalid.

    Returns:

      True if there was something that the plugin did to invalidate. This means that it makes sense to try again. If nothing happens returns False to indicate give up.

    Return type:

      bool

this page last updated: 2026-03-25 21:01:07

Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.

found an error? report a bug