factors: -> stage

This commit is contained in:
Jens Langhammer
2020-05-08 19:46:39 +02:00
parent 08c0eb2ec6
commit 212e966dd4
99 changed files with 745 additions and 958 deletions

View File

View File

@ -0,0 +1,21 @@
"""DummyStage API Views"""
from rest_framework.serializers import ModelSerializer
from rest_framework.viewsets import ModelViewSet
from passbook.stages.dummy.models import DummyStage
class DummyStageSerializer(ModelSerializer):
"""DummyStage Serializer"""
class Meta:
model = DummyStage
fields = ["pk", "name"]
class DummyStageViewSet(ModelViewSet):
"""DummyStage Viewset"""
queryset = DummyStage.objects.all()
serializer_class = DummyStageSerializer

View File

@ -0,0 +1,11 @@
"""passbook dummy stage config"""
from django.apps import AppConfig
class PassbookStageDummyConfig(AppConfig):
"""passbook dummy stage config"""
name = "passbook.stages.dummy"
label = "passbook_stages_dummy"
verbose_name = "passbook Stages.Dummy"

View File

@ -0,0 +1,16 @@
"""passbook administration forms"""
from django import forms
from passbook.stages.dummy.models import DummyStage
class DummyStageForm(forms.ModelForm):
"""Form to create/edit Dummy Stage"""
class Meta:
model = DummyStage
fields = ["name"]
widgets = {
"name": forms.TextInput(),
}

View File

@ -0,0 +1,37 @@
# Generated by Django 3.0.3 on 2020-05-08 17:58
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
("passbook_flows", "0001_initial"),
]
operations = [
migrations.CreateModel(
name="DummyStage",
fields=[
(
"stage_ptr",
models.OneToOneField(
auto_created=True,
on_delete=django.db.models.deletion.CASCADE,
parent_link=True,
primary_key=True,
serialize=False,
to="passbook_flows.Stage",
),
),
],
options={
"verbose_name": "Dummy Stage",
"verbose_name_plural": "Dummy Stages",
},
bases=("passbook_flows.stage",),
),
]

View File

@ -0,0 +1,19 @@
"""dummy stage models"""
from django.utils.translation import gettext as _
from passbook.flows.models import Stage
class DummyStage(Stage):
"""Dummy stage, mostly used to debug"""
type = "passbook.stages.dummy.stage.DummyStage"
form = "passbook.stages.dummy.forms.DummyStageForm"
def __str__(self):
return f"Dummy Stage {self.name}"
class Meta:
verbose_name = _("Dummy Stage")
verbose_name_plural = _("Dummy Stages")

View File

@ -0,0 +1,12 @@
"""passbook multi-stage authentication engine"""
from django.http import HttpRequest
from passbook.flows.stage import AuthenticationStage
class DummyStage(AuthenticationStage):
"""Dummy stage for testing with multiple stages"""
def post(self, request: HttpRequest):
"""Just redirect to next stage"""
return self.executor.stage_ok()