def test_auth_request_token_encoding(self):
        auth_request = AuthRequest(
            self.private_key.to_pem(), self.private_key.public_key().to_hex(),
            self.domain, self.permissions)
        auth_request_token = auth_request.token()

        is_valid_token = AuthRequest.verify(auth_request_token, self.resolver)
        self.assertTrue(is_valid_token)
    def test_custom_openssl_backend(self):
        auth_request = AuthRequest(
            self.private_key_hex, self.public_key_hex,
            self.domain, self.permissions, crypto_backend=openssl_backend)
        auth_request_token = auth_request.token()

        is_valid_token = AuthRequest.verify(auth_request_token, self.resolver)
        self.assertTrue(is_valid_token)
Example #3
0
    def test_custom_openssl_backend(self):
        auth_request = AuthRequest(self.private_key_hex,
                                   self.public_key_hex,
                                   self.domain,
                                   self.permissions,
                                   crypto_backend=openssl_backend)
        auth_request_token = auth_request.token()

        is_valid_token = AuthRequest.verify(auth_request_token, self.resolver)
        self.assertTrue(is_valid_token)
    def test_auth_request_token_encoding(self):
        # valid AuthRequest
        auth_request = AuthRequest(self.private_key_hex, self.domain_name)
        auth_request_token = auth_request.token()

        decoded_token = AuthRequest.decode(auth_request_token)
        payload = decoded_token['payload']
        self.assertEqual(payload['public_keys'][0], self.public_key_hex)
        self.assertEqual(get_address_from_did(payload['iss']), self.public_key.address())
        self.assertEqual(payload['scopes'], [])
        self.assertEqual(payload['manifest_uri'], self.domain_name + '/manifest.json')

        self.assertTrue(AuthRequest.verify(auth_request_token))

        # invalid AuthRequest
        auth_request = AuthRequest(self.private_key_hex, self.domain_name)
        auth_request_token = auth_request.token()[:-1]

        self.assertFalse(AuthRequest.verify(auth_request_token))
Example #5
0
    def test_auth_request_token_encoding(self):
        auth_request = AuthRequest(self.private_key_hex, self.public_key_hex,
                                   self.domain, self.permissions)
        auth_request_token = auth_request.token()

        is_valid_token = AuthRequest.verify(auth_request_token, self.resolver)
        self.assertTrue(is_valid_token)

        decoded_token = AuthRequest.decode(auth_request_token)
        self.assertEqual(decoded_token['payload']['issuer']['publicKey'],
                         self.public_key_hex)
    def test_auth_request_token_encoding(self):
        auth_request = AuthRequest(
            self.private_key_hex, self.public_key_hex,
            self.domain, self.permissions)
        auth_request_token = auth_request.token()

        is_valid_token = AuthRequest.verify(auth_request_token, self.resolver)
        self.assertTrue(is_valid_token)

        decoded_token = AuthRequest.decode(auth_request_token)
        self.assertEqual(decoded_token['payload']['issuer']['publicKey'], self.public_key_hex)
Example #7
0
def blockstack_request(request):
    blockstack_auth_settings = settings.BLOCKSTACK_AUTH['settings']
    blockstack_auth_settings['private_key'] = blockstack_auth_settings.get(
        'private_key', None)
    blockstack_auth_settings['manifest_uri'] = blockstack_auth_settings[
        'domain_name'] + reverse('blockstack:manifest')
    blockstack_auth_settings['redirect_uri'] = blockstack_auth_settings[
        'domain_name'] + reverse('blockstack:response')
    ar = AuthRequest(**blockstack_auth_settings)
    if not AuthRequest.verify(ar.token()):
        return HttpResponse(
            'Can\'t generate Blockstack authentication request token',
            status=500)
    else:
        response = HttpResponse("", status=302)
        response['Location'] = ar.redirect_url()
        return response
 def test_custom_openssl_backend(self):
     auth_request = AuthRequest(self.private_key_hex, self.domain_name, crypto_backend=openssl_backend)
     auth_request_token = auth_request.token()
     self.assertTrue(AuthRequest.verify(auth_request_token))