Example #1
0
def main():
    client_key = crypto.load_key_file("test/keys/id_client")
    server_key = load_key_from_url("http://localhost:8000/pqauth/public-key")

    hello_url = "http://localhost:8000/pqauth/hello"
    confirm_url = "http://localhost:8000/pqauth/confirm"

    authenticator = ClientAuthenticator(client_key, server_key,
                                        hello_url, confirm_url)
    session_key = authenticator.authenticate()
    print "Authentication success, key = %s" % session_key
Example #2
0
def load_server_key():
    try:
        key_path = settings.PQAUTH_SERVER_KEY
    except AttributeError:
        msg = "You must set settings.PQUATH_SERVER_KEY"
        raise ImproperlyConfigured(msg)

    key_password = None
    try:
        key_password = settings.PQAUTH_SERVER_KEY_PASSWORD
    except AttributeError:
        pass

    return load_key_file(key_path, key_password)
Example #3
0
def load_server_key():
    try:
        key_path = settings.PQAUTH_SERVER_KEY
    except AttributeError:
        msg = "You must set settings.PQUATH_SERVER_KEY"
        raise ImproperlyConfigured(msg)

    key_password = None
    try:
        key_password = settings.PQAUTH_SERVER_KEY_PASSWORD
    except AttributeError:
        pass

    return load_key_file(key_path, key_password)
Example #4
0
# A sample logging configuration. The only tangible logging
# performed by this configuration is to send an email to
# the site admins on every HTTP 500 error when DEBUG=False.
# See http://docs.djangoproject.com/en/dev/topics/logging for
# more details on how to customize your logging configuration.
LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'filters': {
        'require_debug_false': {
            '()': 'django.utils.log.RequireDebugFalse'
        }
    },
    'handlers': {
        'mail_admins': {
            'level': 'ERROR',
            'filters': ['require_debug_false'],
            'class': 'django.utils.log.AdminEmailHandler'
        }
    },
    'loggers': {
        'django.request': {
            'handlers': ['mail_admins'],
            'level': 'ERROR',
            'propagate': True,
        },
    }
}

SERVER_KEY = crypto.load_key_file("./server.key")
Example #5
0

########NEW FILE########
__FILENAME__ = protocol
from django.test import TestCase
from django.core.urlresolvers import reverse
from django.conf import settings

from pqauth import crypto
from pqauth.client import PQAuthClient
from pqauth.pqauth_django_server.views import hello
from pqauth.pqauth_django_server.views import confirm
from pqauth.pqauth_django_server.keys import SERVER_KEY
from pqauth.pqauth_django_server.models import PQAuthSession

CLIENT_KEY = crypto.load_key_file(settings.TEST_CLIENT_KEY)
EVIL_KEY = crypto.load_key_file(settings.TEST_EVIL_KEY)


def get_pqa_client():
    return PQAuthClient(CLIENT_KEY, SERVER_KEY)


def get_evil_pqa_client():
    return PQAuthClient(EVIL_KEY, SERVER_KEY)


class ProtocolTest(TestCase):
    fixtures = ["test_accounts.json"]

    def post_hello(self, pqa_client):
Example #6
0
from django.test import TestCase
from django.core.urlresolvers import reverse
from django.conf import settings

from pqauth import crypto
from pqauth.client import PQAuthClient
from pqauth.pqauth_django_server.views import hello
from pqauth.pqauth_django_server.views import confirm
from pqauth.pqauth_django_server.keys import SERVER_KEY
from pqauth.pqauth_django_server.models import PQAuthSession

CLIENT_KEY = crypto.load_key_file(settings.TEST_CLIENT_KEY)
EVIL_KEY = crypto.load_key_file(settings.TEST_EVIL_KEY)


def get_pqa_client():
    return PQAuthClient(CLIENT_KEY, SERVER_KEY)


def get_evil_pqa_client():
    return PQAuthClient(EVIL_KEY, SERVER_KEY)


class ProtocolTest(TestCase):
    fixtures = ["test_accounts.json"]

    def post_hello(self, pqa_client):
        plaintext_message = pqa_client.get_hello_message()
        client_hello = pqa_client.encrypt_for_server(plaintext_message)
        response = self.client.generic("POST",
                                       reverse(hello),