Cleanup and split local/prod

This commit is contained in:
Nico Schottelius 2018-12-30 17:57:02 +01:00
parent f157cf2539
commit 6544fccb9a
8 changed files with 37 additions and 38 deletions

View file

@ -1,6 +1,5 @@
from django.contrib import admin
from django.contrib import admin
from django.contrib.auth.admin import UserAdmin
from .models import OTPSeed

View file

@ -1,7 +1,11 @@
from django.db import models
from django.contrib.auth.models import AbstractUser
# Create your models here.
from rest_framework import exceptions
from rest_framework import authentication
from otpauth.models import OTPSeed
from otpauth.serializer import TokenSerializer
class OTPSeed(AbstractUser):
id = models.AutoField(primary_key=True)
name = models.CharField(max_length=128)
@ -14,25 +18,6 @@ class OTPSeed(AbstractUser):
def __str__(self):
return "'{}'@{}".format(self.name, self.realm)
# @classmethod
# def get_username(cls):
# pass
# @classmethod
# def check_password(cls, raw_password):
# """ receives a time based token"""
# pass
# @classmethod
# def has_usable_password(cls):
# pass
from rest_framework import exceptions
from rest_framework import authentication
from otpauth.models import OTPSeed
from otpauth.serializer import TokenSerializer
class OTPAuthentication(authentication.BaseAuthentication):
def authenticate(self, request):
serializer = TokenSerializer(data=request.data)

View file

@ -4,7 +4,6 @@ from rest_framework import viewsets
from rest_framework.decorators import action
from rest_framework.response import Response
from django.http import JsonResponse
from otpauth.serializer import VerifySerializer, OTPSerializer
from otpauth.models import OTPSeed

View file

@ -2,6 +2,9 @@ pyotp>=2.2.6
django>=2.1.2
djangorestframework
# DB
psycopg2
# Recommended
markdown
django-filter

View file

@ -23,10 +23,6 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
SECRET_KEY = 'h^*!&u7yaac_6t02kk4de%$aagp6_j#+_wnw3@rqu6os0tlv#r'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
@ -72,17 +68,6 @@ TEMPLATES = [
WSGI_APPLICATION = 'ungleichotpserver.wsgi.application'
# Database
# https://docs.djangoproject.com/en/2.1/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
# Password validation
# https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validators
@ -137,3 +122,9 @@ USE_TZ = True
# https://docs.djangoproject.com/en/2.1/howto/static-files/
STATIC_URL = '/static/'
if "DEBUG" in os.environ:
from .local import * # flake8: noqa
else:
from .prod import * # flake8: noqa

View file

@ -0,0 +1,10 @@
DEBUG = True
ALLOWED_HOSTS = []
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}

View file

@ -0,0 +1,12 @@
DEBUG = False
ALLOWED_HOSTS = [
".ungleich.ch"
]
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'app',
}
}

View file

@ -11,6 +11,6 @@ import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'ungleichotp.settings')
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'ungleichotpserver.settings')
application = get_wsgi_application()