Example #1
0
def test_parse_manipulated_cookie_timestamp():
    kaka = ('pyoidc=bjmc::1463043535::upm|'
            '1463043537|18a201305fa15a96ce4048e1fbb03f7715f86499')
    seed = ''
    name = 'pyoidc'
    with pytest.raises(InvalidCookieSign):
        parse_cookie(name, seed, kaka)
Example #2
0
def test_parse_cookie():
    kaka = ('pyoidc=bjmc::1463043535::upm|'
            '1463043535|18a201305fa15a96ce4048e1fbb03f7715f86499')
    seed = ''
    name = 'pyoidc'
    result = parse_cookie(name, seed, kaka)
    assert result == ('bjmc::1463043535::upm', '1463043535')
Example #3
0
def test_parse_cookie():
    kaka = ('pyoidc=bjmc::1463043535::upm|'
            '1463043535|18a201305fa15a96ce4048e1fbb03f7715f86499')
    seed = ''
    name = 'pyoidc'
    result = parse_cookie(name, seed, kaka)
    assert result == ('bjmc::1463043535::upm', '1463043535')
Example #4
0
def factory(kaka, sdb, config):
    """
    Return the right Consumer instance dependent on what's in the cookie

    :param kaka: The cookie
    :param sdb: The session database
    :param config: The common Consumer configuration
    :return: Consumer instance or None
    """
    part = http_util.cookie_parts(config["name"], kaka)
    if part is None:
        return None

    cons = Consumer(sdb, config=config)
    cons.restore(part[0])
    http_util.parse_cookie(config["name"], cons.seed, kaka)
    return cons
Example #5
0
def factory(kaka, sdb, config):
    """
    Return the right Consumer instance dependent on what's in the cookie

    :param kaka: The cookie
    :param sdb: The session database
    :param config: The common Consumer configuration
    :return: Consumer instance or None
    """
    part = http_util.cookie_parts(config["name"], kaka)
    if part is None:
        return None

    cons = Consumer(sdb, config=config)
    cons.restore(part[0])
    http_util.parse_cookie(config["name"], cons.seed, kaka)
    return cons
Example #6
0
def factory(kaka, sdb, client_id, **kwargs):
    """
    Return the right Consumer instance dependent on what's in the cookie.

    :param kaka: The cookie
    :param sdb: The session database
    :param kwargs: The Consumer configuration arguments
    :return: Consumer instance or None
    """
    part = http_util.cookie_parts(client_id, kaka)
    if part is None:
        return None

    cons = Consumer(sdb, **kwargs)
    cons.restore(part[0])
    http_util.parse_cookie(client_id, cons.seed, kaka)
    return cons
Example #7
0
def factory(kaka, sdb, client_id, **kwargs):
    """
    Return the right Consumer instance dependent on what's in the cookie

    :param kaka: The cookie
    :param sdb: The session database
    :param kwargs: The Consumer configuration arguments
    :return: Consumer instance or None
    """
    part = http_util.cookie_parts(client_id, kaka)
    if part is None:
        return None

    cons = Consumer(sdb, **kwargs)
    cons.restore(part[0])
    http_util.parse_cookie(client_id, cons.seed, kaka)
    return cons
Example #8
0
def test_parse_cookie():
    kaka = (
        "pyoidc=bjmc::1463043535::upm|"
        "1463043535|18a201305fa15a96ce4048e1fbb03f7715f86499"
    )
    seed = ""
    name = "pyoidc"
    result = parse_cookie(name, seed, kaka)
    assert result == ("bjmc::1463043535::upm", "1463043535")
Example #9
0
    def getCookieValue(self, cookie=None, cookie_name=None):
        """
        Return information stored in the Cookie

        :param cookie:
        :param cookie_name: The name of the cookie I'm looking for
        :return: tuple (value, timestamp, type)
        """
        if cookie is None or cookie_name is None:
            return None
        else:
            try:
                info, timestamp = parse_cookie(cookie_name,
                                               self.srv.seed, cookie)
                value, _ts, typ = AES_decrypt(self.srv.symkey, info,
                                              self.srv.iv).split("::")
                if timestamp == _ts:
                    return value, _ts, typ
            except Exception:
                pass
        return None