コード例 #1
0
ファイル: test_claims.py プロジェクト: imsoftware/pyoidc
def test_srv2():
    cc = ClaimsClient(client_id="client_1")
    cc.client_secret="hemlig"

    req = cc.construct_UserClaimsRequest(request_args={"user_id": "diana",
                                        "claims_names":["gender", "birthdate"]})

    srv = ClaimsServer("name", None, CDB, FUNCTIONS, USERDB)

    srv.keystore.set_sign_key(rsa_load("rsa.key"), "rsa")
    assert srv

    environ = BASE_ENVIRON.copy()
    environ["REQUEST_METHOD"] = "POST"
    txt = req.to_urlencoded()
    environ["CONTENT_LENGTH"] = len(txt)
    fil = StringIO.StringIO(buf=txt)
    environ["wsgi.input"] = fil

    resp = srv.claims_endpoint(environ, start_response, LOG())

    print resp
    assert len(resp) == 1

    ucr = UserClaimsResponse().deserialize(resp[0], "json")
    ucr.verify(key = srv.keystore.get_keys("sig", owner=None))

    print ucr
    assert _eq(ucr["claims_names"], ["gender", "birthdate"])
    assert "jwt" in ucr
コード例 #2
0
ファイル: broken_server.py プロジェクト: dash-dash/pyoidc
    add_endpoints(endpoints)
    OAS.endpoints = endpoints

    if args.port == 80:
        OAS.baseurl = config.baseurl
    else:
        if config.baseurl.endswith("/"):
            config.baseurl = config.baseurl[:-1]
        OAS.baseurl = "%s:%d" % (config.baseurl, args.port)

    if not OAS.baseurl.endswith("/"):
        OAS.baseurl += "/"

        try:
            for type, info in config.keys.items():
                _rsa = rsa_load(info["key"])
                OAS.keystore.add_key(_rsa, type, "sig")
                OAS.keystore.add_key(_rsa, type, "ver")
                try:
                    name = mv_content(info["cert"], "static")
                    OAS.cert.append(name)
                except KeyError:
                    pass
                try:
                    new_name = mv_content(info["jwk"], "static")
                    OAS.jwk.append("%s%s" % (OAS.baseurl, new_name))
                except KeyError:
                    pass
        except Exception, err:
            OAS.key_setup("static", sig={"format":"jwk", "alg":"rsa"})
コード例 #3
0
ファイル: test_oic.py プロジェクト: imsoftware/pyoidc
from pytest import raises

from fakeoicsrv import MyFakeOICServer


def _eq(l1, l2):
    s1 = set(l1)
    s2 = set(l2)
    return s1 == s2


CLIENT_SECRET = "abcdefghijklmnop"
CLIENT_ID = "client_1"

rsapub = rsa_load("../oc3/certs/mycert.key")

KEYS = [
    ["abcdefghijklmnop", "hmac", "ver", "client_1"],
    ["abcdefghijklmnop", "hmac", "sig", "client_1"],
    [rsapub, "rsa", "sig", "."],
    [rsapub, "rsa", "ver", "."],
]

SIGN_KEY = {"hmac": ["abcdefghijklmnop"]}
IDTOKEN = IdToken(
    iss="http://oic.example.org/", user_id="user_id", aud=CLIENT_ID, exp=time_sans_frac() + 86400, nonce="N0nce"
)

# ----------------- CLIENT --------------------