stages/identification: remove templates

This commit is contained in:
Jens Langhammer 2021-02-20 23:46:56 +01:00
parent 7a9140bdcd
commit 1c8d101fc3
10 changed files with 26 additions and 113 deletions

View File

@ -1,10 +1,10 @@
"""authentik core dataclasses""" """authentik core dataclasses"""
from dataclasses import dataclass from dataclasses import dataclass
from typing import Optional from typing import Optional
from rest_framework.fields import CharField
from rest_framework.serializers import Serializer
from django.db.models.base import Model from django.db.models.base import Model
from rest_framework.fields import CharField
from rest_framework.serializers import Serializer
@dataclass @dataclass

View File

@ -5,7 +5,7 @@ from django.db import migrations
from django.db.backends.base.schema import BaseDatabaseSchemaEditor from django.db.backends.base.schema import BaseDatabaseSchemaEditor
from authentik.flows.models import FlowDesignation from authentik.flows.models import FlowDesignation
from authentik.stages.identification.models import Templates, UserFields from authentik.stages.identification.models import UserFields
def create_default_authentication_flow( def create_default_authentication_flow(
@ -26,7 +26,7 @@ def create_default_authentication_flow(
name="default-authentication-identification", name="default-authentication-identification",
defaults={ defaults={
"user_fields": [UserFields.E_MAIL, UserFields.USERNAME], "user_fields": [UserFields.E_MAIL, UserFields.USERNAME],
"template": Templates.DEFAULT_LOGIN, "template": "",
}, },
) )

View File

@ -15,7 +15,6 @@ class IdentificationStageSerializer(StageSerializer):
"user_fields", "user_fields",
"case_insensitive_matching", "case_insensitive_matching",
"show_matched_user", "show_matched_user",
"template",
"enrollment_flow", "enrollment_flow",
"recovery_flow", "recovery_flow",
] ]

View File

@ -1,12 +1,9 @@
"""authentik flows identification forms""" """authentik flows identification forms"""
from django import forms from django import forms
from django.core.validators import validate_email
from django.utils.translation import gettext_lazy as _
from structlog.stdlib import get_logger from structlog.stdlib import get_logger
from authentik.admin.fields import ArrayFieldSelectMultiple from authentik.admin.fields import ArrayFieldSelectMultiple
from authentik.flows.models import Flow, FlowDesignation from authentik.flows.models import Flow, FlowDesignation
from authentik.lib.utils.ui import human_list
from authentik.stages.identification.models import IdentificationStage, UserFields from authentik.stages.identification.models import IdentificationStage, UserFields
LOGGER = get_logger() LOGGER = get_logger()
@ -32,7 +29,6 @@ class IdentificationStageForm(forms.ModelForm):
"user_fields", "user_fields",
"case_insensitive_matching", "case_insensitive_matching",
"show_matched_user", "show_matched_user",
"template",
"enrollment_flow", "enrollment_flow",
"recovery_flow", "recovery_flow",
] ]

View File

@ -0,0 +1,20 @@
# Generated by Django 3.1.6 on 2021-02-20 22:46
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
(
"authentik_stages_identification",
"0006_identificationstage_show_matched_user",
),
]
operations = [
migrations.RemoveField(
model_name="identificationstage",
name="template",
),
]

View File

@ -18,13 +18,6 @@ class UserFields(models.TextChoices):
USERNAME = "username" USERNAME = "username"
class Templates(models.TextChoices):
"""Templates to be used for the stage"""
DEFAULT_LOGIN = "stages/identification/login.html"
DEFAULT_RECOVERY = "stages/identification/recovery.html"
class IdentificationStage(Stage): class IdentificationStage(Stage):
"""Allows the user to identify themselves for authentication.""" """Allows the user to identify themselves for authentication."""
@ -37,7 +30,6 @@ class IdentificationStage(Stage):
) )
), ),
) )
template = models.TextField(choices=Templates.choices)
case_insensitive_matching = models.BooleanField( case_insensitive_matching = models.BooleanField(
default=True, default=True,

View File

@ -1,5 +1,4 @@
"""Identification stage logic""" """Identification stage logic"""
from authentik.core.types import UILoginButtonSerializer
from dataclasses import asdict from dataclasses import asdict
from typing import Optional from typing import Optional
@ -13,6 +12,7 @@ from structlog.stdlib import get_logger
from authentik.core.api.applications import ApplicationSerializer from authentik.core.api.applications import ApplicationSerializer
from authentik.core.models import Source, User from authentik.core.models import Source, User
from authentik.core.types import UILoginButtonSerializer
from authentik.flows.challenge import Challenge, ChallengeResponse, ChallengeTypes from authentik.flows.challenge import Challenge, ChallengeResponse, ChallengeTypes
from authentik.flows.planner import PLAN_CONTEXT_PENDING_USER from authentik.flows.planner import PLAN_CONTEXT_PENDING_USER
from authentik.flows.stage import ( from authentik.flows.stage import (

View File

@ -1,61 +0,0 @@
{% load i18n %}
{% load static %}
<header class="pf-c-login__main-header">
<h1 class="pf-c-title pf-m-3xl">
{% block card_title %}
{% trans title %}
{% endblock %}
</h1>
</header>
<div class="pf-c-login__main-body">
<form method="POST" class="pf-c-form">
{% block above_form %}
{% if application_pre %}
<p>
{% blocktrans with app_name=application_pre.name %}
Login to continue to <strong id="application-name">{{ app_name }}</strong>.
{% endblocktrans %}
</p>
{% endif %}
{% endblock %}
{% include 'partials/form.html' %}
{% block beneath_form %}
{% endblock %}
<div class="pf-c-form__group pf-m-action">
<button class="pf-c-button pf-m-primary pf-m-block" type="submit">{% trans primary_action %}</button>
</div>
</form>
</div>
<footer class="pf-c-login__main-footer">
<ul class="pf-c-login__main-footer-links">
{% for source in sources %}
<li class="pf-c-login__main-footer-links-item">
<a href="{{ source.url }}" class="pf-c-login__main-footer-links-item-link">
{% if source.icon_url %}
<img src="{{ source.icon_url }}" alt="{{ source.name }}">
{% else %}
<i class="pf-icon pf-icon-arrow" title="{{ source.name }}"></i>
{% endif %}
</a>
</li>
{% endfor %}
</ul>
{% if enroll_url or recovery_url %}
<div class="pf-c-login__main-footer-band">
{% if enroll_url %}
<p class="pf-c-login__main-footer-band-item">
{% trans 'Need an account?' %}
<a role="enroll" href="{{ enroll_url }}">{% trans 'Sign up.' %}</a>
</p>
{% endif %}
{% if recovery_url %}
<p class="pf-c-login__main-footer-band-item">
<a role="recovery" href="{{ recovery_url }}">{% trans 'Forgot username or password?' %}</a>
</p>
{% endif %}
</div>
{% endif %}
</footer>

View File

@ -1,28 +0,0 @@
{% load i18n %}
<header class="pf-c-login__main-header">
<h1 class="pf-c-title pf-m-3xl">
{% trans 'Trouble Logging In?' %}
</h1>
</header>
<div class="pf-c-login__main-body">
{% block card %}
<form method="POST" class="pf-c-form">
{% block above_form %}
{% endblock %}
{% include 'partials/form.html' %}
{% block beneath_form %}
{% endblock %}
<div class="pf-c-form__group pf-m-action">
<button class="pf-c-button pf-m-primary pf-m-block" type="submit">{% trans primary_action %}</button>
</div>
</form>
{% endblock %}
</div>
<footer class="pf-c-login__main-footer">
{% if config.login.subtext %}
<p>{{ config.login.subtext }}</p>
{% endif %}
</footer>

View File

@ -6,11 +6,7 @@ from django.utils.encoding import force_str
from authentik.core.models import User from authentik.core.models import User
from authentik.flows.models import Flow, FlowDesignation, FlowStageBinding from authentik.flows.models import Flow, FlowDesignation, FlowStageBinding
from authentik.sources.oauth.models import OAuthSource from authentik.sources.oauth.models import OAuthSource
from authentik.stages.identification.models import ( from authentik.stages.identification.models import IdentificationStage, UserFields
IdentificationStage,
Templates,
UserFields,
)
class TestIdentificationStage(TestCase): class TestIdentificationStage(TestCase):
@ -29,7 +25,6 @@ class TestIdentificationStage(TestCase):
self.stage = IdentificationStage.objects.create( self.stage = IdentificationStage.objects.create(
name="identification", name="identification",
user_fields=[UserFields.E_MAIL], user_fields=[UserFields.E_MAIL],
template=Templates.DEFAULT_LOGIN,
) )
FlowStageBinding.objects.create( FlowStageBinding.objects.create(
target=self.flow, target=self.flow,