Exemple #1
0
    def sign(self, claims, crypto_key=None):
        """Sign a set of claims.
        :param claims: JSON object containing the JWT claims to use.
        :type claims: dict
        :param crypto_key: Optional existing crypto_key header content. The
            vapid public key will be appended to this data.
        :type crypto_key: str
        :returns: a hash containing the header fields to use in
            the subscription update.
        :rtype: dict

        """
        sig = sign(self._base_sign(claims), self.private_key)
        pkey = 'p256ecdsa='
        pkey += b64urlencode(
            self.public_key.public_bytes(
                serialization.Encoding.X962,
                serialization.PublicFormat.UncompressedPoint
            ))
        if crypto_key:
            crypto_key = crypto_key + ';' + pkey
        else:
            crypto_key = pkey

        return {"Authorization": "{} {}".format(self._schema, sig.strip('=')),
                "Crypto-Key": crypto_key}
Exemple #2
0
    def sign(self, claims, crypto_key=None):
        """Sign a set of claims.
        :param claims: JSON object containing the JWT claims to use.
        :type claims: dict
        :param crypto_key: Optional existing crypto_key header content. The
            vapid public key will be appended to this data.
        :type crypto_key: str
        :returns: a hash containing the header fields to use in
            the subscription update.
        :rtype: dict

        """
        sig = sign(self._base_sign(claims), self.private_key)
        pkey = 'p256ecdsa='
        pkey += b64urlencode(
            self.public_key.public_bytes(
                serialization.Encoding.X962,
                serialization.PublicFormat.UncompressedPoint
            ))
        if crypto_key:
            crypto_key = crypto_key + ';' + pkey
        else:
            crypto_key = pkey

        return {"Authorization": "{} {}".format(self._schema, sig.strip('=')),
                "Crypto-Key": crypto_key}
Exemple #3
0
 def sign(self, claims, crypto_key=None):
     sig = sign(self._base_sign(claims), self.private_key)
     pkey = self.public_key.public_numbers().encode_point()
     return {
         "Authorization":
         "{schema} t={t},k={k}".format(schema=self._schema,
                                       t=sig,
                                       k=b64urlencode(pkey))
     }
Exemple #4
0
 def sign(self, claims, crypto_key=None):
     sig = sign(self._base_sign(claims), self.private_key)
     pkey = self.public_key.public_bytes(
         serialization.Encoding.X962,
         serialization.PublicFormat.UncompressedPoint)
     return {
         "Authorization":
         "{schema} t={t},k={k}".format(schema=self._schema,
                                       t=sig,
                                       k=b64urlencode(pkey))
     }
Exemple #5
0
 def sign(self, claims, crypto_key=None):
     sig = sign(self._base_sign(claims), self.private_key)
     pkey = self.public_key.public_bytes(
             serialization.Encoding.X962,
             serialization.PublicFormat.UncompressedPoint
         )
     return{
         "Authorization": "{schema} t={t},k={k}".format(
             schema=self._schema,
             t=sig,
             k=b64urlencode(pkey)
         )
     }