stages/login: -> stages/user_login: rename login to user_login for user_create stage
This commit is contained in:
parent
4315d1a03c
commit
f111604b70
|
@ -34,10 +34,10 @@ from passbook.sources.oauth.api import OAuthSourceViewSet
|
||||||
from passbook.stages.captcha.api import CaptchaStageViewSet
|
from passbook.stages.captcha.api import CaptchaStageViewSet
|
||||||
from passbook.stages.email.api import EmailStageViewSet
|
from passbook.stages.email.api import EmailStageViewSet
|
||||||
from passbook.stages.identification.api import IdentificationStageViewSet
|
from passbook.stages.identification.api import IdentificationStageViewSet
|
||||||
from passbook.stages.login.api import LoginStageViewSet
|
|
||||||
from passbook.stages.otp.api import OTPStageViewSet
|
from passbook.stages.otp.api import OTPStageViewSet
|
||||||
from passbook.stages.password.api import PasswordStageViewSet
|
from passbook.stages.password.api import PasswordStageViewSet
|
||||||
from passbook.stages.prompt.api import PromptStageViewSet, PromptViewSet
|
from passbook.stages.prompt.api import PromptStageViewSet, PromptViewSet
|
||||||
|
from passbook.stages.user_login.api import UserLoginStageViewSet
|
||||||
|
|
||||||
LOGGER = get_logger()
|
LOGGER = get_logger()
|
||||||
router = routers.DefaultRouter()
|
router = routers.DefaultRouter()
|
||||||
|
@ -83,7 +83,7 @@ router.register("stages/email", EmailStageViewSet)
|
||||||
router.register("stages/otp", OTPStageViewSet)
|
router.register("stages/otp", OTPStageViewSet)
|
||||||
router.register("stages/password", PasswordStageViewSet)
|
router.register("stages/password", PasswordStageViewSet)
|
||||||
router.register("stages/identification", IdentificationStageViewSet)
|
router.register("stages/identification", IdentificationStageViewSet)
|
||||||
router.register("stages/login", LoginStageViewSet)
|
router.register("stages/user_login", UserLoginStageViewSet)
|
||||||
router.register("stages/prompt", PromptStageViewSet)
|
router.register("stages/prompt", PromptStageViewSet)
|
||||||
router.register("stages/prompt/prompts", PromptViewSet)
|
router.register("stages/prompt/prompts", PromptViewSet)
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ def create_default_flow(apps: Apps, schema_editor: BaseDatabaseSchemaEditor):
|
||||||
Flow = apps.get_model("passbook_flows", "Flow")
|
Flow = apps.get_model("passbook_flows", "Flow")
|
||||||
FlowStageBinding = apps.get_model("passbook_flows", "FlowStageBinding")
|
FlowStageBinding = apps.get_model("passbook_flows", "FlowStageBinding")
|
||||||
PasswordStage = apps.get_model("passbook_stages_password", "PasswordStage")
|
PasswordStage = apps.get_model("passbook_stages_password", "PasswordStage")
|
||||||
LoginStage = apps.get_model("passbook_stages_login", "LoginStage")
|
UserLoginStage = apps.get_model("passbook_stages_user_login", "UserLoginStage")
|
||||||
IdentificationStage = apps.get_model(
|
IdentificationStage = apps.get_model(
|
||||||
"passbook_stages_identification", "IdentificationStage"
|
"passbook_stages_identification", "IdentificationStage"
|
||||||
)
|
)
|
||||||
|
@ -34,12 +34,12 @@ def create_default_flow(apps: Apps, schema_editor: BaseDatabaseSchemaEditor):
|
||||||
name="password", backends=["django.contrib.auth.backends.ModelBackend"],
|
name="password", backends=["django.contrib.auth.backends.ModelBackend"],
|
||||||
)
|
)
|
||||||
|
|
||||||
if not LoginStage.objects.using(db_alias).exists():
|
if not UserLoginStage.objects.using(db_alias).exists():
|
||||||
LoginStage.objects.using(db_alias).create(name="authentication")
|
UserLoginStage.objects.using(db_alias).create(name="authentication")
|
||||||
|
|
||||||
ident_stage = IdentificationStage.objects.using(db_alias).first()
|
ident_stage = IdentificationStage.objects.using(db_alias).first()
|
||||||
pw_stage = PasswordStage.objects.using(db_alias).first()
|
pw_stage = PasswordStage.objects.using(db_alias).first()
|
||||||
login_stage = LoginStage.objects.using(db_alias).first()
|
login_stage = UserLoginStage.objects.using(db_alias).first()
|
||||||
flow = Flow.objects.using(db_alias).create(
|
flow = Flow.objects.using(db_alias).create(
|
||||||
name="default-authentication-flow",
|
name="default-authentication-flow",
|
||||||
slug="default-authentication-flow",
|
slug="default-authentication-flow",
|
||||||
|
@ -60,7 +60,7 @@ class Migration(migrations.Migration):
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
("passbook_flows", "0001_initial"),
|
("passbook_flows", "0001_initial"),
|
||||||
("passbook_stages_login", "0001_initial"),
|
("passbook_stages_user_login", "0001_initial"),
|
||||||
("passbook_stages_password", "0001_initial"),
|
("passbook_stages_password", "0001_initial"),
|
||||||
("passbook_stages_identification", "0001_initial"),
|
("passbook_stages_identification", "0001_initial"),
|
||||||
]
|
]
|
||||||
|
|
|
@ -104,10 +104,10 @@ INSTALLED_APPS = [
|
||||||
"passbook.sources.saml.apps.PassbookSourceSAMLConfig",
|
"passbook.sources.saml.apps.PassbookSourceSAMLConfig",
|
||||||
"passbook.stages.captcha.apps.PassbookStageCaptchaConfig",
|
"passbook.stages.captcha.apps.PassbookStageCaptchaConfig",
|
||||||
"passbook.stages.dummy.apps.PassbookStageDummyConfig",
|
"passbook.stages.dummy.apps.PassbookStageDummyConfig",
|
||||||
"passbook.stages.login.apps.PassbookStageLoginConfig",
|
|
||||||
"passbook.stages.email.apps.PassbookStageEmailConfig",
|
"passbook.stages.email.apps.PassbookStageEmailConfig",
|
||||||
"passbook.stages.prompt.apps.PassbookStagPromptConfig",
|
"passbook.stages.prompt.apps.PassbookStagPromptConfig",
|
||||||
"passbook.stages.identification.apps.PassbookStageIdentificationConfig",
|
"passbook.stages.identification.apps.PassbookStageIdentificationConfig",
|
||||||
|
"passbook.stages.user_login.apps.PassbookStageUserLoginConfig",
|
||||||
"passbook.stages.otp.apps.PassbookStageOTPConfig",
|
"passbook.stages.otp.apps.PassbookStageOTPConfig",
|
||||||
"passbook.stages.password.apps.PassbookStagePasswordConfig",
|
"passbook.stages.password.apps.PassbookStagePasswordConfig",
|
||||||
"passbook.static.apps.PassbookStaticConfig",
|
"passbook.static.apps.PassbookStaticConfig",
|
||||||
|
|
|
@ -1,24 +0,0 @@
|
||||||
"""Login Stage API Views"""
|
|
||||||
from rest_framework.serializers import ModelSerializer
|
|
||||||
from rest_framework.viewsets import ModelViewSet
|
|
||||||
|
|
||||||
from passbook.stages.login.models import LoginStage
|
|
||||||
|
|
||||||
|
|
||||||
class LoginStageSerializer(ModelSerializer):
|
|
||||||
"""LoginStage Serializer"""
|
|
||||||
|
|
||||||
class Meta:
|
|
||||||
|
|
||||||
model = LoginStage
|
|
||||||
fields = [
|
|
||||||
"pk",
|
|
||||||
"name",
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
class LoginStageViewSet(ModelViewSet):
|
|
||||||
"""LoginStage Viewset"""
|
|
||||||
|
|
||||||
queryset = LoginStage.objects.all()
|
|
||||||
serializer_class = LoginStageSerializer
|
|
|
@ -1,10 +0,0 @@
|
||||||
"""passbook login stage app config"""
|
|
||||||
from django.apps import AppConfig
|
|
||||||
|
|
||||||
|
|
||||||
class PassbookStageLoginConfig(AppConfig):
|
|
||||||
"""passbook login stage config"""
|
|
||||||
|
|
||||||
name = "passbook.stages.login"
|
|
||||||
label = "passbook_stages_login"
|
|
||||||
verbose_name = "passbook Stages.Login"
|
|
|
@ -1,16 +0,0 @@
|
||||||
"""passbook flows login forms"""
|
|
||||||
from django import forms
|
|
||||||
|
|
||||||
from passbook.stages.login.models import LoginStage
|
|
||||||
|
|
||||||
|
|
||||||
class LoginStageForm(forms.ModelForm):
|
|
||||||
"""Form to create/edit LoginStage instances"""
|
|
||||||
|
|
||||||
class Meta:
|
|
||||||
|
|
||||||
model = LoginStage
|
|
||||||
fields = ["name"]
|
|
||||||
widgets = {
|
|
||||||
"name": forms.TextInput(),
|
|
||||||
}
|
|
|
@ -1,19 +0,0 @@
|
||||||
"""login stage models"""
|
|
||||||
from django.utils.translation import gettext_lazy as _
|
|
||||||
|
|
||||||
from passbook.flows.models import Stage
|
|
||||||
|
|
||||||
|
|
||||||
class LoginStage(Stage):
|
|
||||||
"""Login stage, allows a user to identify themselves to authenticate."""
|
|
||||||
|
|
||||||
type = "passbook.stages.login.stage.LoginStageView"
|
|
||||||
form = "passbook.stages.login.forms.LoginStageForm"
|
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
return f"Login Stage {self.name}"
|
|
||||||
|
|
||||||
class Meta:
|
|
||||||
|
|
||||||
verbose_name = _("Login Stage")
|
|
||||||
verbose_name_plural = _("Login Stages")
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
"""Login Stage API Views"""
|
||||||
|
from rest_framework.serializers import ModelSerializer
|
||||||
|
from rest_framework.viewsets import ModelViewSet
|
||||||
|
|
||||||
|
from passbook.stages.user_login.models import UserLoginStage
|
||||||
|
|
||||||
|
|
||||||
|
class UserLoginStageSerializer(ModelSerializer):
|
||||||
|
"""UserLoginStage Serializer"""
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
|
||||||
|
model = UserLoginStage
|
||||||
|
fields = [
|
||||||
|
"pk",
|
||||||
|
"name",
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
class UserLoginStageViewSet(ModelViewSet):
|
||||||
|
"""UserLoginStage Viewset"""
|
||||||
|
|
||||||
|
queryset = UserLoginStage.objects.all()
|
||||||
|
serializer_class = UserLoginStageSerializer
|
|
@ -0,0 +1,10 @@
|
||||||
|
"""passbook login stage app config"""
|
||||||
|
from django.apps import AppConfig
|
||||||
|
|
||||||
|
|
||||||
|
class PassbookStageUserLoginConfig(AppConfig):
|
||||||
|
"""passbook login stage config"""
|
||||||
|
|
||||||
|
name = "passbook.stages.user_login"
|
||||||
|
label = "passbook_stages_user_login"
|
||||||
|
verbose_name = "passbook Stages.User Login"
|
|
@ -0,0 +1,16 @@
|
||||||
|
"""passbook flows login forms"""
|
||||||
|
from django import forms
|
||||||
|
|
||||||
|
from passbook.stages.user_login.models import UserLoginStage
|
||||||
|
|
||||||
|
|
||||||
|
class UserLoginStageForm(forms.ModelForm):
|
||||||
|
"""Form to create/edit UserLoginStage instances"""
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
|
||||||
|
model = UserLoginStage
|
||||||
|
fields = ["name"]
|
||||||
|
widgets = {
|
||||||
|
"name": forms.TextInput(),
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
# Generated by Django 3.0.3 on 2020-05-09 20:26
|
# Generated by Django 3.0.5 on 2020-05-10 14:03
|
||||||
|
|
||||||
import django.db.models.deletion
|
import django.db.models.deletion
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
|
@ -14,7 +14,7 @@ class Migration(migrations.Migration):
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
migrations.CreateModel(
|
migrations.CreateModel(
|
||||||
name="LoginStage",
|
name="UserLoginStage",
|
||||||
fields=[
|
fields=[
|
||||||
(
|
(
|
||||||
"stage_ptr",
|
"stage_ptr",
|
||||||
|
@ -29,8 +29,8 @@ class Migration(migrations.Migration):
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
options={
|
options={
|
||||||
"verbose_name": "Login Stage",
|
"verbose_name": "User Login Stage",
|
||||||
"verbose_name_plural": "Login Stages",
|
"verbose_name_plural": "User Login Stages",
|
||||||
},
|
},
|
||||||
bases=("passbook_flows.stage",),
|
bases=("passbook_flows.stage",),
|
||||||
),
|
),
|
|
@ -0,0 +1,19 @@
|
||||||
|
"""login stage models"""
|
||||||
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
|
from passbook.flows.models import Stage
|
||||||
|
|
||||||
|
|
||||||
|
class UserLoginStage(Stage):
|
||||||
|
"""Login stage, allows a user to identify themselves to authenticate."""
|
||||||
|
|
||||||
|
type = "passbook.stages.user_login.stage.UserLoginStageView"
|
||||||
|
form = "passbook.stages.user_login.forms.UserLoginStageForm"
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return f"User Login Stage {self.name}"
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
|
||||||
|
verbose_name = _("User Login Stage")
|
||||||
|
verbose_name_plural = _("User Login Stages")
|
|
@ -12,7 +12,7 @@ from passbook.stages.password.stage import PLAN_CONTEXT_AUTHENTICATION_BACKEND
|
||||||
LOGGER = get_logger()
|
LOGGER = get_logger()
|
||||||
|
|
||||||
|
|
||||||
class LoginStageView(AuthenticationStage):
|
class UserLoginStageView(AuthenticationStage):
|
||||||
"""Finalise Authentication flow by logging the user in"""
|
"""Finalise Authentication flow by logging the user in"""
|
||||||
|
|
||||||
def get(self, request: HttpRequest) -> HttpResponse:
|
def get(self, request: HttpRequest) -> HttpResponse:
|
|
@ -6,11 +6,11 @@ from passbook.core.models import User
|
||||||
from passbook.flows.models import Flow, FlowDesignation, FlowStageBinding
|
from passbook.flows.models import Flow, FlowDesignation, FlowStageBinding
|
||||||
from passbook.flows.planner import PLAN_CONTEXT_PENDING_USER, FlowPlan
|
from passbook.flows.planner import PLAN_CONTEXT_PENDING_USER, FlowPlan
|
||||||
from passbook.flows.views import SESSION_KEY_PLAN
|
from passbook.flows.views import SESSION_KEY_PLAN
|
||||||
from passbook.stages.login.models import LoginStage
|
|
||||||
from passbook.stages.password.stage import PLAN_CONTEXT_AUTHENTICATION_BACKEND
|
from passbook.stages.password.stage import PLAN_CONTEXT_AUTHENTICATION_BACKEND
|
||||||
|
from passbook.stages.user_login.models import UserLoginStage
|
||||||
|
|
||||||
|
|
||||||
class TestLoginStage(TestCase):
|
class TestUserLoginStage(TestCase):
|
||||||
"""Login tests"""
|
"""Login tests"""
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
@ -23,7 +23,7 @@ class TestLoginStage(TestCase):
|
||||||
slug="test-login",
|
slug="test-login",
|
||||||
designation=FlowDesignation.AUTHENTICATION,
|
designation=FlowDesignation.AUTHENTICATION,
|
||||||
)
|
)
|
||||||
self.stage = LoginStage.objects.create(name="login")
|
self.stage = UserLoginStage.objects.create(name="login")
|
||||||
FlowStageBinding.objects.create(flow=self.flow, stage=self.stage, order=2)
|
FlowStageBinding.objects.create(flow=self.flow, stage=self.stage, order=2)
|
||||||
|
|
||||||
def test_valid_password(self):
|
def test_valid_password(self):
|
Reference in New Issue