コード例 #1
0
ファイル: client.py プロジェクト: tallmad/pqauth
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
コード例 #2
0
ファイル: allPythonContent.py プロジェクト: Mondego/pyreco
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)
コード例 #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)
コード例 #4
0
ファイル: settings.py プロジェクト: tallmad/pqauth
# 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")
コード例 #5
0
ファイル: allPythonContent.py プロジェクト: Mondego/pyreco

########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):
コード例 #6
0
ファイル: protocol.py プロジェクト: ddtrung-fs/pqauth
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),