예제 #1
0
 def test_keys(self):
     self.setup_package()
     verify_keys(self.pay_jwt_dict(),
                 ('iss', 'typ', 'aud', 'iat', 'exp', 'request.name',
                  'request.description', 'request.pricePoint',
                  'request.postbackURL', 'request.chargebackURL',
                  'request.productData'))
예제 #2
0
 def test_keys(self):
     verify_keys(self.token_data,
                 ('iss',
                  'typ',
                  'aud',
                  'iat',
                  'exp',
                  'request.name',
                  'request.description',
                  'request.pricePoint',
                  'request.postbackURL',
                  'request.chargebackURL',
                  'request.productData'))
예제 #3
0
 def test_keys(self):
     verify_keys(self.decode_token(),
                 ('iss',
                  'typ',
                  'aud',
                  'iat',
                  'exp',
                  'request.name',
                  'request.description',
                  'request.pricePoint',
                  'request.postbackURL',
                  'request.chargebackURL',
                  'request.productData'))
예제 #4
0
 def test_keys(self):
     self.setup_package()
     verify_keys(self.pay_jwt_dict(),
                 ('iss',
                  'typ',
                  'aud',
                  'iat',
                  'exp',
                  'request.name',
                  'request.description',
                  'request.pricePoint',
                  'request.postbackURL',
                  'request.chargebackURL',
                  'request.productData'))
예제 #5
0
 def test_keys(self):
     verify_keys(
         self.decode_token(),
         (
             "iss",
             "typ",
             "aud",
             "iat",
             "exp",
             "request.name",
             "request.description",
             "request.pricePoint",
             "request.postbackURL",
             "request.chargebackURL",
             "request.productData",
         ),
     )
예제 #6
0
 def test_keys(self):
     self.setup_package()
     verify_keys(
         self.pay_jwt_dict(),
         (
             "iss",
             "typ",
             "aud",
             "iat",
             "exp",
             "request.name",
             "request.description",
             "request.pricePoint",
             "request.postbackURL",
             "request.chargebackURL",
             "request.productData",
         ),
     )
예제 #7
0
def verify_webpay_jwt(signed_jwt):
    # This can probably be deleted depending upon solitude.
    try:
        jwt.decode(signed_jwt.encode('ascii'), secret)
    except Exception, e:
        log.error('Error decoding webpay jwt: %s' % e, exc_info=True)
        return {'valid': False}
    return {'valid': True}


def sign_webpay_jwt(data):
    return jwt.encode(data, secret)


def parse_from_webpay(signed_jwt, ip):
    try:
        data = jwt.decode(signed_jwt.encode('ascii'), secret)
    except Exception, e:
        log.info('Received invalid webpay postback from IP %s: %s' %
                 (ip or '(unknown)', e), exc_info=True)
        raise InvalidSender()

    verify_claims(data)
    iss, aud, product_data, trans_id = verify_keys(
        data,
        ('iss', 'aud', 'request.productData', 'response.transactionID'))
    log.info('Received webpay postback JWT: iss:%s aud:%s '
             'trans_id:%s product_data:%s'
             % (iss, aud, trans_id, product_data))
    return data