Begin setup of new auth system

This commit is contained in:
Nico Schottelius 2021-12-05 18:59:19 +01:00
parent 01e8c827ab
commit bdd97f4eeb
7 changed files with 100 additions and 5 deletions

View File

@ -21,3 +21,49 @@ pip install -r requirements.txt
* Configure the `dal` django app (uses the [decouple](https://pypi.org/project/python-decouple/) library underneath)
- Copy `dal/env.sample` to `dal/.env`
- Populate `dal/.env`
## Functionality
- Allow user to register in a specific subtree
- Verify that user does not exist in another subtree
- Assign an id
- Allow password reset via Mail
- DB usage: for password reset?
## Parameters
LDAPSERVER
## Steps / Views
### Register view
Form: [get]
* captcha?
* username
* password1
* password2
Post receiver: [post]
* Validation / check if human
* E-Mail verification
E-Mail verify: [get]
* Create user
### Password reset view
* captcha
* username
## Tech notes
### django-auth-ldap
Depends on python-ldap, which fails on Alpine at the moment:
* https://django-auth-ldap.readthedocs.io/en/latest/

View File

@ -1,10 +1,10 @@
django==3.2.9
django==4.0rc1
django-auth-ldap
python-ldap
# To check
django-bootstrap3
django-filter==2.1.0
python-decouple
ldap3
djangorestframework
pyotp
requests

View File

@ -0,0 +1,3 @@
{% block content %}
Your content here
{% endblock %}

View File

@ -0,0 +1,38 @@
{% extends "base.html" %}
{% block content %}
{% if form.errors %}
<p>Your username and password didn't match. Please try again.</p>
{% endif %}
{% if next %}
{% if user.is_authenticated %}
<p>Your account doesn't have access to this page. To proceed,
please login with an account that has access.</p>
{% else %}
<p>Please login to see this page.</p>
{% endif %}
{% endif %}
<form method="post" action="{% url 'login' %}">
{% csrf_token %}
<table>
<tr>
<td>{{ form.username.label_tag }}</td>
<td>{{ form.username }}</td>
</tr>
<tr>
<td>{{ form.password.label_tag }}</td>
<td>{{ form.password }}</td>
</tr>
</table>
<input type="submit" value="login">
<input type="hidden" name="next" value="{{ next }}">
</form>
{# Assumes you setup the password_reset view in your URLconf #}
<p><a href="{% url 'password_reset' %}">Lost password?</a></p>
{% endblock %}

View File

@ -10,6 +10,7 @@ For the full list of settings and their values, see
https://docs.djangoproject.com/en/dev/ref/settings/
"""
import os
from pathlib import Path
# Build paths inside the project like this: BASE_DIR / 'subdir'.
@ -54,7 +55,7 @@ ROOT_URLCONF = 'ungleichuser.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'DIRS': [os.path.join(BASE_DIR, 'templates')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [

View File

@ -14,8 +14,10 @@ Including another URLconf
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path
import django.contrib.auth
from django.urls import path, include
urlpatterns = [
path('admin/', admin.site.urls),
path('accounts/', include('django.contrib.auth.urls')),
]

View File

@ -0,0 +1,5 @@
import ipaddress
import random
v4_addr = ipaddress.IPv4Address(random.randint(0, 2**32))
v6_addr = ipaddress.IPv6Address(random.randint(0, 2**128)