From cdb45bd1f0225d1a73a01bd20af7087a114e91e5 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 17 Nov 2018 21:45:53 +0100 Subject: [PATCH] Update readme, auth ideas --- README.md | 15 ++++++++++++++- ungleichotp/otpauth/models.py | 15 +++++++++++++++ ungleichotp/ungleichotp/urls.py | 3 ++- 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6a0b5df..e5dece4 100644 --- a/README.md +++ b/README.md @@ -283,10 +283,23 @@ class ExampleAuthentication(authentication.BaseAuthentication): ``` +Custom user + +Don’t forget to point AUTH_USER_MODEL to it. Do this before creating any migrations or running manage.py migrate for the first time. + + + ## TODOs - [x] serialize / input request - [ ] Remove hard coded JSON - [ ] Implement registering of new entries -- [ ] Use Custom authentication (?) - set User +- [ ] Use Custom authentication (?) - needs to have a user - [ ] Maybe we map name+realm == User (?) + - name == name@realm + - no password + - seed + - custom auth method +- [ ] Implement creating new "User" + - by POST / Model based +- [ ] Implement deleting "User" diff --git a/ungleichotp/otpauth/models.py b/ungleichotp/otpauth/models.py index 29e9606..8075db0 100644 --- a/ungleichotp/otpauth/models.py +++ b/ungleichotp/otpauth/models.py @@ -1,4 +1,5 @@ from django.db import models +from django.contrib.auth.models import AbstractUser # Create your models here. class OTPSeed(models.Model): @@ -12,3 +13,17 @@ class OTPSeed(models.Model): def __str__(self): return "'{}'@{}".format(self.name, self.realm) + +# class OTPUser(AbstractUser, OTPSeed): +# @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 diff --git a/ungleichotp/ungleichotp/urls.py b/ungleichotp/ungleichotp/urls.py index 02cefba..740f82c 100644 --- a/ungleichotp/ungleichotp/urls.py +++ b/ungleichotp/ungleichotp/urls.py @@ -21,11 +21,12 @@ from django.conf.urls import url, include from django.contrib.auth.models import User from rest_framework import routers, serializers, viewsets from otpauth.models import OTPSeed -from otpauth.views import VerifyViewSet +from otpauth.views import ModelVerifyViewSet, VerifyViewSet router = routers.DefaultRouter() router.register(r'ungleichotp', VerifyViewSet, basename='ungleichotp') +router.register(r'ungleichotpv2', ModelVerifyViewSet, basename='ungleichotpv2') print(router.urls)