Revert "*: providers and sources -> channels, PolicyModel to PolicyBindingModel that uses custom M2M through"

This reverts commit 7ed3ceb960.
This commit is contained in:
Jens Langhammer
2020-05-16 16:02:42 +02:00
parent 7ed3ceb960
commit 406f69080b
293 changed files with 4692 additions and 3244 deletions

View File

@ -1,4 +1,4 @@
# Generated by Django 3.0.5 on 2020-05-15 19:59
# Generated by Django 3.0.3 on 2020-05-08 17:58
import django.db.models.deletion
from django.db import migrations, models

View File

@ -1,4 +1,4 @@
# Generated by Django 3.0.5 on 2020-05-15 19:59
# Generated by Django 3.0.3 on 2020-05-08 17:58
import django.db.models.deletion
from django.db import migrations, models

View File

@ -1,4 +1,4 @@
# Generated by Django 3.0.5 on 2020-05-15 19:59
# Generated by Django 3.0.3 on 2020-05-08 17:59
import django.db.models.deletion
from django.db import migrations, models
@ -34,33 +34,12 @@ class Migration(migrations.Migration):
("use_tls", models.BooleanField(default=False)),
("use_ssl", models.BooleanField(default=False)),
("timeout", models.IntegerField(default=10)),
("ssl_keyfile", models.TextField(blank=True, default=None, null=True)),
("ssl_certfile", models.TextField(blank=True, default=None, null=True)),
(
"from_address",
models.EmailField(default="system@passbook.local", max_length=254),
),
(
"token_expiry",
models.IntegerField(
default=30, help_text="Time in minutes the token sent is valid."
),
),
("subject", models.TextField(default="passbook")),
(
"template",
models.TextField(
choices=[
(
"stages/email/for_email/password_reset.html",
"Password Reset",
),
(
"stages/email/for_email/account_confirmation.html",
"Account Confirmation",
),
],
default="stages/email/for_email/password_reset.html",
),
),
],
options={
"verbose_name": "Email Stage",

View File

@ -0,0 +1,22 @@
# Generated by Django 3.0.5 on 2020-05-10 18:44
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("passbook_stages_email", "0001_initial"),
]
operations = [
migrations.RemoveField(model_name="emailstage", name="ssl_certfile",),
migrations.RemoveField(model_name="emailstage", name="ssl_keyfile",),
migrations.AddField(
model_name="emailstage",
name="token_expiry",
field=models.IntegerField(
default=30, help_text="Time in minutes the token sent is valid."
),
),
]

View File

@ -0,0 +1,32 @@
# Generated by Django 3.0.5 on 2020-05-15 12:42
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("passbook_stages_email", "0002_auto_20200510_1844"),
]
operations = [
migrations.AddField(
model_name="emailstage",
name="subject",
field=models.TextField(default="passbook"),
),
migrations.AddField(
model_name="emailstage",
name="template",
field=models.TextField(
choices=[
("stages/email/for_email/password_reset.html", "Password Reset"),
(
"stages/email/for_email/account_confirmation.html",
"Account Confirmation",
),
],
default="stages/email/for_email/password_reset.html",
),
),
]

View File

@ -10,7 +10,7 @@ from django.utils.translation import gettext as _
from django.views.generic import FormView
from structlog import get_logger
from passbook.core.models import Token
from passbook.core.models import Nonce
from passbook.flows.planner import PLAN_CONTEXT_PENDING_USER
from passbook.flows.stage import AuthenticationStage
from passbook.stages.email.forms import EmailStageSendForm
@ -38,9 +38,9 @@ class EmailStageView(FormView, AuthenticationStage):
def get(self, request: HttpRequest, *args, **kwargs) -> HttpResponse:
if QS_KEY_TOKEN in request.GET:
token = get_object_or_404(Token, pk=request.GET[QS_KEY_TOKEN])
self.executor.plan.context[PLAN_CONTEXT_PENDING_USER] = token.user
token.delete()
nonce = get_object_or_404(Nonce, pk=request.GET[QS_KEY_TOKEN])
self.executor.plan.context[PLAN_CONTEXT_PENDING_USER] = nonce.user
nonce.delete()
messages.success(request, _("Successfully verified E-Mail."))
return self.executor.stage_ok()
return super().get(request, *args, **kwargs)
@ -50,16 +50,16 @@ class EmailStageView(FormView, AuthenticationStage):
valid_delta = timedelta(
minutes=self.executor.current_stage.token_expiry + 1
) # + 1 because django timesince always rounds down
token = Token.objects.create(user=pending_user, expires=now() + valid_delta)
nonce = Nonce.objects.create(user=pending_user, expires=now() + valid_delta)
# Send mail to user
message = TemplateEmailMessage(
subject=_("passbook - Password Recovery"),
template_name=self.executor.current_stage.template,
to=[pending_user.email],
template_context={
"url": self.get_full_url(**{QS_KEY_TOKEN: token.pk.hex}),
"url": self.get_full_url(**{QS_KEY_TOKEN: nonce.pk.hex}),
"user": pending_user,
"expires": token.expires,
"expires": nonce.expires,
},
)
send_mails(self.executor.current_stage, message)

View File

@ -5,7 +5,7 @@ from django.core import mail
from django.shortcuts import reverse
from django.test import Client, TestCase
from passbook.core.models import Token, User
from passbook.core.models import Nonce, User
from passbook.flows.models import Flow, FlowDesignation, FlowStageBinding
from passbook.flows.planner import PLAN_CONTEXT_PENDING_USER, FlowPlan
from passbook.flows.views import SESSION_KEY_PLAN
@ -77,7 +77,7 @@ class TestEmailStage(TestCase):
url = reverse(
"passbook_flows:flow-executor", kwargs={"flow_slug": self.flow.slug}
)
token = Token.objects.get(user=self.user)
token = Nonce.objects.get(user=self.user)
url += f"?{QS_KEY_TOKEN}={token.pk.hex}"
response = self.client.get(url)
self.assertEqual(response.status_code, 302)

View File

@ -1,4 +1,4 @@
# Generated by Django 3.0.5 on 2020-05-15 19:59
# Generated by Django 3.0.3 on 2020-05-09 18:34
import django.contrib.postgres.fields
import django.db.models.deletion
@ -32,22 +32,14 @@ class Migration(migrations.Migration):
"user_fields",
django.contrib.postgres.fields.ArrayField(
base_field=models.CharField(
choices=[("email", "E Mail"), ("username", "Username")],
choices=[("e-mail", "E Mail"), ("username", "Username")],
max_length=100,
),
help_text="Fields of the user object to match against.",
size=None,
),
),
(
"template",
models.TextField(
choices=[
("stages/identification/login.html", "Default Login"),
("stages/identification/recovery.html", "Default Recovery"),
]
),
),
("template", models.TextField()),
],
options={
"verbose_name": "Identification Stage",

View File

@ -0,0 +1,18 @@
# Generated by Django 3.0.3 on 2020-05-09 19:16
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("passbook_stages_identification", "0001_initial"),
]
operations = [
migrations.AlterField(
model_name="identificationstage",
name="template",
field=models.TextField(choices=[("login/form.html", "Default Login")]),
),
]

View File

@ -0,0 +1,26 @@
# Generated by Django 3.0.3 on 2020-05-09 20:25
import django.contrib.postgres.fields
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("passbook_stages_identification", "0002_auto_20200509_1916"),
]
operations = [
migrations.AlterField(
model_name="identificationstage",
name="user_fields",
field=django.contrib.postgres.fields.ArrayField(
base_field=models.CharField(
choices=[("email", "E Mail"), ("username", "Username")],
max_length=100,
),
help_text="Fields of the user object to match against.",
size=None,
),
),
]

View File

@ -0,0 +1,23 @@
# Generated by Django 3.0.5 on 2020-05-10 16:48
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("passbook_stages_identification", "0003_auto_20200509_2025"),
]
operations = [
migrations.AlterField(
model_name="identificationstage",
name="template",
field=models.TextField(
choices=[
("stages/identification/login.html", "Default Login"),
("stages/identification/recovery.html", "Default Recovery"),
]
),
),
]

View File

@ -9,7 +9,7 @@ from django.utils.translation import gettext as _
from django.views.generic import FormView
from structlog import get_logger
from passbook.core.models import Inlet, User
from passbook.core.models import Source, User
from passbook.flows.models import FlowDesignation
from passbook.flows.planner import PLAN_CONTEXT_PENDING_USER
from passbook.flows.stage import AuthenticationStage
@ -49,12 +49,14 @@ class IdentificationStageView(FormView, AuthenticationStage):
)
# Check all enabled source, add them if they have a UI Login button.
kwargs["inlets"] = []
inlets = Inlet.objects.filter(enabled=True).order_by("name").select_subclasses()
for source in inlets:
kwargs["sources"] = []
sources = (
Source.objects.filter(enabled=True).order_by("name").select_subclasses()
)
for source in sources:
ui_login_button = source.ui_login_button
if ui_login_button:
kwargs["inlets"].append(ui_login_button)
kwargs["sources"].append(ui_login_button)
return super().get_context_data(**kwargs)
def get_user(self, uid_value: str) -> Optional[User]:

View File

@ -2,9 +2,9 @@
from django.shortcuts import reverse
from django.test import Client, TestCase
from passbook.channels.in_oauth.models import OAuthInlet
from passbook.core.models import User
from passbook.flows.models import Flow, FlowDesignation, FlowStageBinding
from passbook.sources.oauth.models import OAuthSource
from passbook.stages.identification.models import (
IdentificationStage,
Templates,
@ -34,8 +34,8 @@ class TestIdentificationStage(TestCase):
flow=self.flow, stage=self.stage, order=0,
)
# OAuthInlet for the login view
OAuthInlet.objects.create(name="test", slug="test")
# OAuthSource for the login view
OAuthSource.objects.create(name="test", slug="test")
def test_valid_render(self):
"""Test that View renders correctly"""

View File

@ -1,4 +1,4 @@
# Generated by Django 3.0.5 on 2020-05-15 19:59
# Generated by Django 3.0.5 on 2020-05-11 19:09
import uuid
@ -13,7 +13,7 @@ class Migration(migrations.Migration):
initial = True
dependencies = [
("passbook_flows", "0001_initial"),
("passbook_flows", "0004_auto_20200510_2310"),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
@ -32,13 +32,6 @@ class Migration(migrations.Migration):
to="passbook_flows.Stage",
),
),
(
"continue_flow_without_invitation",
models.BooleanField(
default=False,
help_text="If this flag is set, this Stage will jump to the next Stage when no Invitation is given. By default this Stage will cancel the Flow when no invitation is given.",
),
),
],
options={
"verbose_name": "Invitation Stage",

View File

@ -0,0 +1,21 @@
# Generated by Django 3.0.5 on 2020-05-11 19:46
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("passbook_stages_invitation", "0001_initial"),
]
operations = [
migrations.AddField(
model_name="invitationstage",
name="continue_flow_without_invitation",
field=models.BooleanField(
default=False,
help_text="If this flag is set, this Stage will jump to the next Stage when no Invitation is given. By default this Stage will cancel the Flow when no invitation is given.",
),
),
]

View File

@ -1,4 +1,4 @@
# Generated by Django 3.0.5 on 2020-05-15 19:59
# Generated by Django 3.0.3 on 2020-05-08 17:59
import django.db.models.deletion
from django.db import migrations, models

View File

@ -1,4 +1,4 @@
# Generated by Django 3.0.5 on 2020-05-15 19:59
# Generated by Django 3.0.3 on 2020-05-08 17:58
import django.contrib.postgres.fields
import django.db.models.deletion
@ -11,6 +11,7 @@ class Migration(migrations.Migration):
dependencies = [
("passbook_flows", "0001_initial"),
("passbook_core", "0012_delete_factor"),
]
operations = [
@ -36,6 +37,10 @@ class Migration(migrations.Migration):
size=None,
),
),
(
"password_policies",
models.ManyToManyField(blank=True, to="passbook_core.Policy"),
),
],
options={
"verbose_name": "Password Stage",

View File

@ -0,0 +1,14 @@
# Generated by Django 3.0.5 on 2020-05-10 16:48
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
("passbook_stages_password", "0001_initial"),
]
operations = [
migrations.RemoveField(model_name="passwordstage", name="password_policies",),
]

View File

@ -1,4 +1,4 @@
# Generated by Django 3.0.5 on 2020-05-15 19:59
# Generated by Django 3.0.5 on 2020-05-14 11:46
import uuid
@ -11,8 +11,8 @@ class Migration(migrations.Migration):
initial = True
dependencies = [
("passbook_flows", "0001_initial"),
("passbook_policies", "0001_initial"),
("passbook_flows", "0005_auto_20200512_1158"),
("passbook_policies", "0003_auto_20200508_1642"),
]
operations = [

View File

@ -1,4 +1,4 @@
# Generated by Django 3.0.5 on 2020-05-15 19:59
# Generated by Django 3.0.5 on 2020-05-12 11:59
import django.db.models.deletion
from django.db import migrations, models
@ -9,7 +9,7 @@ class Migration(migrations.Migration):
initial = True
dependencies = [
("passbook_flows", "0001_initial"),
("passbook_flows", "0005_auto_20200512_1158"),
]
operations = [

View File

@ -1,4 +1,4 @@
# Generated by Django 3.0.5 on 2020-05-15 19:59
# Generated by Django 3.0.5 on 2020-05-10 14:03
import django.db.models.deletion
from django.db import migrations, models

View File

@ -1,4 +1,4 @@
# Generated by Django 3.0.5 on 2020-05-15 19:59
# Generated by Django 3.0.5 on 2020-05-10 22:56
import django.db.models.deletion
from django.db import migrations, models

View File

@ -1,4 +1,4 @@
# Generated by Django 3.0.5 on 2020-05-15 19:59
# Generated by Django 3.0.5 on 2020-05-10 21:21
import django.db.models.deletion
from django.db import migrations, models
@ -9,7 +9,7 @@ class Migration(migrations.Migration):
initial = True
dependencies = [
("passbook_flows", "0001_initial"),
("passbook_flows", "0003_auto_20200509_1258"),
]
operations = [