Cleanup, expose seed read only
This commit is contained in:
parent
d95c8dbd9c
commit
6f7d02f7fc
3 changed files with 22 additions and 1 deletions
|
@ -292,6 +292,7 @@ Don’t forget to point AUTH_USER_MODEL to it. Do this before creating any migra
|
||||||
## TODOs
|
## TODOs
|
||||||
|
|
||||||
- [x] serialize / input request
|
- [x] serialize / input request
|
||||||
|
- [x] Make seed read only
|
||||||
- [ ] Remove hard coded JSON
|
- [ ] Remove hard coded JSON
|
||||||
- [ ] Implement registering of new entries
|
- [ ] Implement registering of new entries
|
||||||
- [ ] Use Custom authentication (?) - needs to have a user
|
- [ ] Use Custom authentication (?) - needs to have a user
|
||||||
|
@ -303,3 +304,4 @@ Don’t forget to point AUTH_USER_MODEL to it. Do this before creating any migra
|
||||||
- [ ] Implement creating new "User"
|
- [ ] Implement creating new "User"
|
||||||
- by POST / Model based
|
- by POST / Model based
|
||||||
- [ ] Implement deleting "User"
|
- [ ] Implement deleting "User"
|
||||||
|
- [ ] OTPSerializer: allow to read seed for admin
|
||||||
|
|
|
@ -6,7 +6,9 @@ import otpauth
|
||||||
class OTPSerializer(serializers.ModelSerializer):
|
class OTPSerializer(serializers.ModelSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = OTPSeed
|
model = OTPSeed
|
||||||
fields = ('name', 'realm')
|
fields = ('name', 'realm', 'seed')
|
||||||
|
read_only_fields = ('seed',)
|
||||||
|
|
||||||
|
|
||||||
class VerifySerializer(serializers.Serializer):
|
class VerifySerializer(serializers.Serializer):
|
||||||
name = serializers.CharField(max_length=128)
|
name = serializers.CharField(max_length=128)
|
||||||
|
@ -18,6 +20,7 @@ class VerifySerializer(serializers.Serializer):
|
||||||
verifyrealm = serializers.CharField(max_length=128)
|
verifyrealm = serializers.CharField(max_length=128)
|
||||||
|
|
||||||
def create(self, validated_data):
|
def create(self, validated_data):
|
||||||
|
print("all going to be verified - CREATE")
|
||||||
token_in = validated_data.get('token')
|
token_in = validated_data.get('token')
|
||||||
name_in = validated_data.get('name')
|
name_in = validated_data.get('name')
|
||||||
realm_in = validated_data.get('realm')
|
realm_in = validated_data.get('realm')
|
||||||
|
@ -55,3 +58,6 @@ class VerifySerializer(serializers.Serializer):
|
||||||
|
|
||||||
print("All verified!")
|
print("All verified!")
|
||||||
return verifyinstance
|
return verifyinstance
|
||||||
|
|
||||||
|
def verify(self, validated_data):
|
||||||
|
print("all going to be verified - AAAAAAAA")
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
|
|
||||||
from rest_framework import viewsets
|
from rest_framework import viewsets
|
||||||
from rest_framework.parsers import JSONParser
|
from rest_framework.parsers import JSONParser
|
||||||
|
from rest_framework.decorators import action
|
||||||
|
from rest_framework.response import Response
|
||||||
|
|
||||||
|
|
||||||
from django.http import HttpResponse, JsonResponse
|
from django.http import HttpResponse, JsonResponse
|
||||||
|
|
||||||
|
@ -11,6 +15,15 @@ class OTPVerifyViewSet(viewsets.ModelViewSet):
|
||||||
serializer_class = OTPSerializer
|
serializer_class = OTPSerializer
|
||||||
queryset = OTPSeed.objects.all()
|
queryset = OTPSeed.objects.all()
|
||||||
|
|
||||||
|
@action(detail=False, methods=['post'])
|
||||||
|
def verify(self, request):
|
||||||
|
serializer = VerifySerializer(data=request.data)
|
||||||
|
if serializer.is_valid():
|
||||||
|
print(serializer)
|
||||||
|
return Response({'status': 'OK'})
|
||||||
|
|
||||||
|
return JsonResponse(serializer.errors, status=400)
|
||||||
|
|
||||||
|
|
||||||
class VerifyViewSet(viewsets.ViewSet):
|
class VerifyViewSet(viewsets.ViewSet):
|
||||||
serializer_class = VerifySerializer
|
serializer_class = VerifySerializer
|
||||||
|
|
Loading…
Reference in a new issue