How to use the jwcrypto.common.json_decode function in jwcrypto

To help you get started, we’ve selected a few jwcrypto examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github davedoesdev / python-jwt / test / View on Github external
def spawn(cmd, parse_json):
    """ run node command """
    #pylint: disable=E1101
    with lock:
        p = Popen(["node", "-e", "fixtures=require('./test/fixtures');" + cmd],
                  stdout=PIPE, stderr=PIPE)
        (stdout, stderr) = p.communicate()
    stdout = stdout.decode('utf-8')
    stderr = stderr.decode('utf-8')
    if p.returncode == 0:
        return json_decode(stdout) if parse_json else stdout
    raise Exception(stderr if stderr else ('exited with {}'.format(p.returncode)))
    #pylint: enable=E1101
github latchset / custodia / src / custodia / message / View on Github external
def decode_enc_kem(message, enc_key, sig_key):
    jwe = JWT(jwt=message, key=enc_key)
    jws = JWT(, key=sig_key)
    return json_decode(
github latchset / custodia / src / custodia / View on Github external
def _decode_key(self, key):
        if key is None:
            return None
        elif isinstance(key, JWK):
            return key
        elif isinstance(key, dict):
            return JWK(**key)
        elif isinstance(key, str):
            return JWK(**(json_decode(key)))
            raise TypeError("Invalid key type")
github davedoesdev / python-jwt / python_jwt / View on Github external
claims['jti'] = base64url_encode(urandom(jti_size))

    claims['nbf'] = timegm((not_before or now).utctimetuple())
    claims['iat'] = timegm(now.utctimetuple())

    if lifetime:
        claims['exp'] = timegm((now + lifetime).utctimetuple())
    elif expires:
        claims['exp'] = timegm(expires.utctimetuple())

    if header['alg'] == 'none':
        signature = ''
        token = JWS(json_encode(claims))
        token.add_signature(priv_key, protected=header)
        signature = json_decode(token.serialize())['signature']

    return u'%s.%s.%s' % (
github latchset / custodia / src / custodia / message / View on Github external
def server_keys(self):
        if self._server_keys is None:
            if 'server_keys' not in self.config:
                raise UnknownPublicKey("Server Keys not defined")
            skey = self.find_key(self.config['server_keys'], KEY_USAGE_SIG)
            ekey = self.find_key(self.config['server_keys'], KEY_USAGE_ENC)
            self._server_keys = [JWK(**(json_decode(skey))),
        return self._server_keys