Exemple #1
0
        if u'pubkey' in kw.get(u'authextra', dict()):
            pubkey = kw[u'authextra'][u'pubkey']
            if pubkey != self._privkey.public_key():
                raise ValueError(
                    "Public key doesn't correspond to private key"
                )
        else:
            kw[u'authextra'] = kw.get(u'authextra', dict())
            kw[u'authextra'][u'pubkey'] = self._privkey.public_key()
        self._args = kw

    def on_challenge(self, session, challenge):
        return self._privkey.sign_challenge(session, challenge)


IAuthenticator.register(AuthCryptoSign)


class AuthWampCra(object):

    def __init__(self, **kw):
        # should put in checkconfig or similar
        for key in kw.keys():
            if key not in [u'authextra', u'authid', u'authrole', u'secret']:
                raise ValueError(
                    "Unexpected key '{}' for {}".format(key, self.__class__.__name__)
                )
        for key in [u'secret', u'authid']:
            if key not in kw:
                raise ValueError(
                    "Must provide '{}' for wampcra".format(key)
Exemple #2
0
    def __init__(self, **kw):
        self._args = kw

    @property
    def authextra(self):
        return self._args.get('authextra', dict())

    def on_challenge(self, session, challenge):
        raise RuntimeError("on_challenge called on anonymous authentication")

    def on_welcome(self, msg, authextra):
        return None


IAuthenticator.register(AuthAnonymous)


class AuthTicket(object):
    name = 'ticket'

    def __init__(self, **kw):
        self._args = kw
        try:
            self._ticket = self._args.pop('ticket')
        except KeyError:
            raise ValueError("ticket authentication requires 'ticket=' kwarg")

    @property
    def authextra(self):
        return self._args.get('authextra', dict())
Exemple #3
0
    name = u'anonymous'

    def __init__(self, **kw):
        self._args = kw

    @property
    def authextra(self):
        return self._args.get(u'authextra', dict())

    def on_challenge(self, session, challenge):
        raise RuntimeError(
            "on_challenge called on anonymous authentication"
        )


IAuthenticator.register(AuthAnonymous)


class AuthTicket(object):
    name = u'ticket'

    def __init__(self, **kw):
        self._args = kw
        try:
            self._ticket = self._args.pop(u'ticket')
        except KeyError:
            raise ValueError(
                "ticket authentication requires 'ticket=' kwarg"
            )

    @property