Add django-user-accounts app for use in place of SSO

This commit is contained in:
Ben Sturmfels 2023-04-20 00:00:00 +10:00
parent ecfa3c1fce
commit 64b4d93470
Signed by: bsturmfels
GPG key ID: 023C05E2C9C068F0
6 changed files with 97 additions and 2 deletions

View file

@ -3,7 +3,6 @@ AUTHENTICATION_BACKENDS = [
'symposion.teams.backends.TeamPermissionsBackend', 'symposion.teams.backends.TeamPermissionsBackend',
'django.contrib.auth.backends.ModelBackend', 'django.contrib.auth.backends.ModelBackend',
] ]
LOGIN_URL='/accounts/login'
ROOT_URLCONF = "pinaxcon.devmode_urls" ROOT_URLCONF = "pinaxcon.devmode_urls"

View file

@ -170,6 +170,7 @@ TEMPLATES = [
"django.template.context_processors.request", "django.template.context_processors.request",
"django.contrib.messages.context_processors.messages", "django.contrib.messages.context_processors.messages",
"pinax_theme_bootstrap.context_processors.theme", "pinax_theme_bootstrap.context_processors.theme",
"account.context_processors.account",
"symposion.reviews.context_processors.reviews", "symposion.reviews.context_processors.reviews",
"django_settings_export.settings_export", "django_settings_export.settings_export",
], ],
@ -183,6 +184,8 @@ MIDDLEWARE = [
"django.middleware.common.CommonMiddleware", "django.middleware.common.CommonMiddleware",
"django.middleware.csrf.CsrfViewMiddleware", "django.middleware.csrf.CsrfViewMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware", "django.contrib.auth.middleware.AuthenticationMiddleware",
"account.middleware.LocaleMiddleware",
"account.middleware.TimezoneMiddleware",
"djangosaml2.middleware.SamlSessionMiddleware", "djangosaml2.middleware.SamlSessionMiddleware",
"django.contrib.messages.middleware.MessageMiddleware", "django.contrib.messages.middleware.MessageMiddleware",
"debug_toolbar.middleware.DebugToolbarMiddleware", "debug_toolbar.middleware.DebugToolbarMiddleware",
@ -267,6 +270,8 @@ INSTALLED_APPS = [
"waffle", "waffle",
"crispy_forms", "crispy_forms",
"account",
] ]
CRISPY_TEMPLATE_PACK = "bootstrap4" CRISPY_TEMPLATE_PACK = "bootstrap4"
@ -356,7 +361,7 @@ AUTHENTICATION_BACKENDS = [
'djangosaml2.backends.Saml2Backend', 'djangosaml2.backends.Saml2Backend',
] ]
LOGIN_URL = '/saml2/login/' LOGIN_URL = '/account/login/'
SESSION_EXPIRE_AT_BROWSER_CLOSE = True SESSION_EXPIRE_AT_BROWSER_CLOSE = True
CONFERENCE_ID = 2 CONFERENCE_ID = 2
@ -582,3 +587,7 @@ VENUELESS_URL = os.environ.get('VENUELESS_URL', None)
VENUELESS_AUDIENCE = os.environ.get('VENUELESS_AUDIENCE', "venueless") VENUELESS_AUDIENCE = os.environ.get('VENUELESS_AUDIENCE', "venueless")
VENUELESS_TOKEN_ISSUER = os.environ.get('VENUELESS_TOKEN_ISSUER', "any") VENUELESS_TOKEN_ISSUER = os.environ.get('VENUELESS_TOKEN_ISSUER', "any")
VENUELESS_SECRET = os.environ.get('VENUELESS_SECRET', SECRET_KEY) VENUELESS_SECRET = os.environ.get('VENUELESS_SECRET', SECRET_KEY)
ACCOUNT_SIGNUP_REDIRECT_URL = '/dashboard/'
ACCOUNT_LOGIN_REDIRECT_URL = '/dashboard/'

View file

@ -0,0 +1,43 @@
{% extends "site_base.html" %}
{% load account_tags %}
{% load i18n %}
{% load bootstrap %}
{% block head_title %}{% trans "Log in" %}{% endblock %}
{% block content %}
<div class="row">
<div class="col-md-4">
<form method="POST" action="{% url "account_login" %}" autocapitalize="off" {% if form.is_multipart %} enctype="multipart/form-data"{% endif %}>
<legend>{% trans "Log in to an existing account" %}</legend>
{% csrf_token %}
{{ form|bootstrap }}
{% if redirect_field_value %}
<input type="hidden" name="{{ redirect_field_name }}" value="{{ redirect_field_value }}" />
{% endif %}
<button type="submit" class="btn btn-primary">{% trans "Log in" %}</button>
<a href="{% url "account_password_reset" %}" class="btn btn-link">{% trans "Forgot your password?" %}</a>
</form>
{% if ACCOUNT_OPEN_SIGNUP %}
<p class="login-signup">
<small>
{% trans "Don't have an account?" %} <strong><a href="{% urlnext 'account_signup' %}">{% trans "Sign up" %}</a></strong>
</small>
</p>
{% endif %}
</div>
<div class="col-md-4">
{% include "account/_login_sidebar.html" %}
</div>
</div>
{% endblock %}
{% block scripts %}
{{ block.super }}
<script type="text/javascript">
$(document).ready(function() {
$('#id_username').focus();
});
</script>
{% endblock %}

View file

@ -0,0 +1,41 @@
{% extends "site_base.html" %}
{% load account_tags %}
{% load i18n %}
{% load bootstrap %}
{% block head_title %}Sign up{% endblock %}
{% block page_title %}Sign up{% endblock %}
{% block alert %}
{% endblock %}
{% block content %}
<div class="row">
<div class="col-md-4">
<form id="signup_form" method="post" action="{% url "account_signup" %}" autocapitalize="off" {% if form.is_multipart %} enctype="multipart/form-data"{% endif %}>
{% csrf_token %}
{{ form|bootstrap }}
{% if redirect_field_value %}
<input type="hidden" name="{{ redirect_field_name }}" value="{{ redirect_field_value }}" />
{% endif %}
<button type="submit" class="btn btn-primary">{% trans "Sign up" %}</button>
</form>
<p class="login-signup">
<small>
{% trans "Already have an account?" %} <strong><a href="{% urlnext 'account_login' %}">{% trans "Log in" %}</a></strong>
</small>
</p>
</div>
<div class="col-md-4">
{% include "account/_signup_sidebar.html" %}
</div>
</div>
{% endblock %} <!-- block content -->
{% block scripts_extra %}
<script type="text/javascript">
$(document).ready(function() {
$('#id_username').focus();
});
</script>
{% endblock %}

View file

@ -24,6 +24,8 @@ urlpatterns = [
path("teams/", include("symposion.teams.urls")), path("teams/", include("symposion.teams.urls")),
path('raffle/', include("pinaxcon.raffle.urls")), path('raffle/', include("pinaxcon.raffle.urls")),
path("account/", include("account.urls")),
# Required by registrasion # Required by registrasion
path('tickets/payments/', include('registripe.urls')), path('tickets/payments/', include('registripe.urls')),
path('tickets/', include('registrasion.urls')), path('tickets/', include('registrasion.urls')),

View file

@ -50,3 +50,4 @@ django-sass-processor==0.8.2
django-compressor==2.4 django-compressor==2.4
django-crispy-forms==1.9.2 django-crispy-forms==1.9.2
django-user-accounts==3.2.0