Esempio n. 1
0
    def get_endpoint(self, **kwargs):
        """Get an endpoint as provided by the auth plugin."""
        if not self.auth:
            raise exceptions.MissingAuthPlugin('An auth plugin is required to '
                                               'determine the endpoint URL.')

        return self.auth.get_endpoint(self, **kwargs)
Esempio n. 2
0
    def get_token(self, auth=None):
        """Return a token as provided by the auth plugin.

        :param auth: The auth plugin to use for token. Overrides the plugin
                     on the session. (optional)
        :type auth: :py:class:`keystoneclient.auth.base.BaseAuthPlugin`

        :raises keystoneclient.exceptions.AuthorizationFailure: if a new token
                                                                fetch fails.
        :raises keystoneclient.exceptions.MissingAuthPlugin: if a plugin is not
                                                             available.

        :returns: A valid token.
        :rtype: string
        """
        if not auth:
            auth = self.auth

        if not auth:
            raise exceptions.MissingAuthPlugin(_("Token Required"))

        try:
            return auth.get_token(self)
        except exceptions.HttpError as exc:
            raise exceptions.AuthorizationFailure(
                _("Authentication failure: %s") % exc)
Esempio n. 3
0
    def _auth_required(self, auth, msg):
        if not auth:
            auth = self.auth

        if not auth:
            raise exceptions.MissingAuthPlugin(msg)

        return auth
Esempio n. 4
0
    def _auth_required(self, auth, msg):
        if not auth:
            auth = self.auth

        if not auth:
            msg_fmt = _('An auth plugin is required to %s')
            raise exceptions.MissingAuthPlugin(msg_fmt % msg)

        return auth
    def invalidate(self, auth=None):
        """Invalidate an authentication plugin.
        """
        if not auth:
            auth = self.auth

        if not auth:
            msg = 'Auth plugin not available to invalidate'
            raise exceptions.MissingAuthPlugin(msg)

        return auth.invalidate()
Esempio n. 6
0
    def get_token(self):
        """Return a token as provided by the auth plugin.

        :raises AuthorizationFailure: if a new token fetch fails.

        :returns string: A valid token.
        """
        if not self.auth:
            raise exceptions.MissingAuthPlugin("Token Required")

        try:
            return self.auth.get_token(self)
        except exceptions.HTTPError as exc:
            raise exceptions.AuthorizationFailure("Authentication failure: "
                                                  "%s" % exc)
Esempio n. 7
0
    def invalidate(self, auth=None):
        """Invalidate an authentication plugin.

        :param auth: The auth plugin to invalidate. Overrides the plugin on the
                     session. (optional)
        :type auth: :py:class:`keystoneclient.auth.base.BaseAuthPlugin`

        """
        if not auth:
            auth = self.auth

        if not auth:
            msg = _('Auth plugin not available to invalidate')
            raise exceptions.MissingAuthPlugin(msg)

        return auth.invalidate()
    def get_endpoint(self, auth=None, **kwargs):
        """Get an endpoint as provided by the auth plugin.

        :param auth: The auth plugin to use for token. Overrides the plugin on
                     the session. (optional)
        :type auth: :class:`keystoneclient.auth.base.BaseAuthPlugin`

        :raises MissingAuthPlugin: if a plugin is not available.

        :returns string: An endpoint if available or None.
        """
        if not auth:
            auth = self.auth

        if not auth:
            raise exceptions.MissingAuthPlugin('An auth plugin is required to '
                                               'determine the endpoint URL.')

        return auth.get_endpoint(self, **kwargs)
Esempio n. 9
0
    def get_token(self):
        """Return a token as provided by the auth plugin."""
        if not self.auth:
            raise exceptions.MissingAuthPlugin("Token Required")

        return self.auth.get_token(self)