Example #1
0
    def test_algo_parameter_removes_alg_from_algorithms_list(self, jws):
        assert 'none' in jws.get_algorithms()
        assert 'HS256' in jws.get_algorithms()

        jws = PyJWS(algorithms=['HS256'])
        assert 'none' not in jws.get_algorithms()
        assert 'HS256' in jws.get_algorithms()
Example #2
0
    def test_algo_parameter_removes_alg_from_algorithms_list(self, jws):
        assert "none" in jws.get_algorithms()
        assert "HS256" in jws.get_algorithms()

        jws = PyJWS(algorithms=["HS256"])
        assert "none" not in jws.get_algorithms()
        assert "HS256" in jws.get_algorithms()
Example #3
0
    def test_ecdsa_related_algorithms(self, jws):
        jws = PyJWS()
        jws_algorithms = jws.get_algorithms()

        if has_crypto:
            assert "ES256" in jws_algorithms
            assert "ES384" in jws_algorithms
            assert "ES521" in jws_algorithms
        else:
            assert "ES256" not in jws_algorithms
            assert "ES384" not in jws_algorithms
            assert "ES521" not in jws_algorithms
    def test_ecdsa_related_algorithms(self, jws):
        jws = PyJWS()
        jws_algorithms = jws.get_algorithms()

        if has_crypto:
            assert 'ES256' in jws_algorithms
            assert 'ES384' in jws_algorithms
            assert 'ES512' in jws_algorithms
        else:
            assert 'ES256' not in jws_algorithms
            assert 'ES384' not in jws_algorithms
            assert 'ES512' not in jws_algorithms
Example #5
0
    def test_rsa_related_algorithms(self, jws):
        jws = PyJWS()
        jws_algorithms = jws.get_algorithms()

        if has_crypto:
            assert "RS256" in jws_algorithms
            assert "RS384" in jws_algorithms
            assert "RS512" in jws_algorithms
            assert "PS256" in jws_algorithms
            assert "PS384" in jws_algorithms
            assert "PS512" in jws_algorithms

        else:
            assert "RS256" not in jws_algorithms
            assert "RS384" not in jws_algorithms
            assert "RS512" not in jws_algorithms
            assert "PS256" not in jws_algorithms
            assert "PS384" not in jws_algorithms
            assert "PS512" not in jws_algorithms
Example #6
0
    def test_override_options(self):
        jws = PyJWS(options={"verify_signature": False})

        assert not jws.options["verify_signature"]
Example #7
0
def jws():
    return PyJWS()
Example #8
0
from flask import flash
from flask import redirect
from flask import render_template
from flask import request
from flask import url_for
from flask.ext.login import LoginManager
from flask.ext.login import current_user
from flask.ext.login import login_required
from flask.ext.login import login_user
from flask.ext.login import logout_user
from jwt.api_jws import PyJWS
import flask
import jwt
import requests

jws = PyJWS()

not_alpha_numeric = re.compile('[^a-zA-Z0-9]+')

required = {
    'base_url': {
        'description': 'the base URL for your Okta org',
        'example': 'https://example.okta.com'
    },
    'api_token': {
        'description': 'the API token for your Okta org',
        'example': '01A2bCd3efGh-ij-4K-Lmn5OPqrSTuvwXYZaBCD6EF'
    },
    'client_id': {
        'description': 'an OAuth Client ID for your Okta org',
        'example': 'a0bcdEfGhIJkLmNOPQr1'
Example #9
0
def decode_rs512(payload):
    rsa_pub_file = open(os.path.expanduser('~/.ssh/id_rsa.pub'), 'r')
    pub_rsakey = load_ssh_public_key(force_bytes(rsa_pub_file.read()),
                                     backend=default_backend())
    return PyJWS().decode(payload, pub_rsakey)