コード例 #1
0
ファイル: models.py プロジェクト: hdknr/connect
    def get_id_token(self):
        id_token_string = self.get_id_token_string()

        if not id_token_string:
            return None

        # IdToken object
        id_token = IdToken.parse(id_token_string, sender=self.authority, recipient=self.party)
        self.id_token_object = id_token
        self.save()
        return self.id_token_object  # has "verified" fields
コード例 #2
0
ファイル: rp.py プロジェクト: hdknr/connect
        def run(self, params, **options):
            signon = SignOn.objects.get(id=params.id[0])
            id_token_string = signon.get_id_token_string()

            # TODO: SIOP routeine should be moved somewhere else
            if signon.authority.vender == "connect.venders.self":
                print "SIOP"
                id_token = IdToken.parse_siop_token(id_token_string)
                signon.verified = id_token.verified
                signon.id_token_object = id_token
                signon.save()
                print id_token.to_json(indent=2)

            print "*** Tokens ****"
            for token in signon.rp_token_related.all():
                print token.id, token.created_at, token.token
コード例 #3
0
ファイル: rp.py プロジェクト: hdknr/connect
        def run(self, params, **options):
            so = SignOn.objects.get(id=params.id[0])
            res = TokenRes.from_json(so.tokens)
            id_token_str = res.id_token
            id_token_header = IdToken.header(id_token_str)
            jwk = id_token_header.load_key(so.authority)
            print "Party:", so.party.id, so.party
            print "Authoryt:", so.party.authority.id, so.party.authority
            print "Token Header:", id_token_header and id_token_header.to_json(indent=2)
            print "Key :", jwk and jwk.to_json(indent=2)

            try:
                so = SignOn.objects.get(id=params.id[0])
                print so.id_token_object.to_json(indent=2)
                print "JWT is  verified:", so.id_token_object.verified
            except JoseException, ex:
                print ex.message
                print ex.jobj and ex.jobj.to_json()
                print ex.args
コード例 #4
0
ファイル: auth.py プロジェクト: hdknr/connect
def res_implicit(request, vender, action, mode):
    """
    """
    authres = AuthRes.from_url(request.get_full_path())
    valid_state = authres.state == request.session["state"]
    if not valid_state:
        raise Exception("Invalid State")

    if not authres.id_token:
        raise Exception("No ID Token")

    signon = None
    errors = None
    try:
        signon = SignOn.objects.get(state=authres.state)

        # Save AuthRes
        signon.response_object = authres

        # Save Id Token
        id_token_string = signon.get_id_token_string()
        if id_token_string:
            id_token = IdToken.parse_siop_token(id_token_string)
            signon.verified = id_token.verified
            signon.id_token_object = id_token
            signon.subject = id_token.sub

        signon.save()

        if authres.error:
            raise Exception("authres error")

        save_signon(request, signon)
        return bind(request, signon)

    except Exception, ex:
        errors = traceback.format_exc()
        if signon:
            signon.errors = errors
            signon.save()