Begin setup of new auth system
This commit is contained in:
parent
01e8c827ab
commit
bdd97f4eeb
7 changed files with 100 additions and 5 deletions
46
README.md
46
README.md
|
@ -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)
|
* Configure the `dal` django app (uses the [decouple](https://pypi.org/project/python-decouple/) library underneath)
|
||||||
- Copy `dal/env.sample` to `dal/.env`
|
- Copy `dal/env.sample` to `dal/.env`
|
||||||
- Populate `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/
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
django==3.2.9
|
django==4.0rc1
|
||||||
django-auth-ldap
|
django-auth-ldap
|
||||||
python-ldap
|
|
||||||
|
# To check
|
||||||
django-bootstrap3
|
django-bootstrap3
|
||||||
django-filter==2.1.0
|
django-filter==2.1.0
|
||||||
python-decouple
|
python-decouple
|
||||||
ldap3
|
ldap3
|
||||||
djangorestframework
|
djangorestframework
|
||||||
pyotp
|
|
||||||
requests
|
requests
|
||||||
|
|
3
ungleichuser/templates/base.html
Normal file
3
ungleichuser/templates/base.html
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
{% block content %}
|
||||||
|
Your content here
|
||||||
|
{% endblock %}
|
38
ungleichuser/templates/registration/login.html
Normal file
38
ungleichuser/templates/registration/login.html
Normal 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 %}
|
|
@ -10,6 +10,7 @@ For the full list of settings and their values, see
|
||||||
https://docs.djangoproject.com/en/dev/ref/settings/
|
https://docs.djangoproject.com/en/dev/ref/settings/
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import os
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
||||||
|
@ -54,7 +55,7 @@ ROOT_URLCONF = 'ungleichuser.urls'
|
||||||
TEMPLATES = [
|
TEMPLATES = [
|
||||||
{
|
{
|
||||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||||
'DIRS': [],
|
'DIRS': [os.path.join(BASE_DIR, 'templates')],
|
||||||
'APP_DIRS': True,
|
'APP_DIRS': True,
|
||||||
'OPTIONS': {
|
'OPTIONS': {
|
||||||
'context_processors': [
|
'context_processors': [
|
||||||
|
|
|
@ -14,8 +14,10 @@ Including another URLconf
|
||||||
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
||||||
"""
|
"""
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.urls import path
|
import django.contrib.auth
|
||||||
|
from django.urls import path, include
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('admin/', admin.site.urls),
|
path('admin/', admin.site.urls),
|
||||||
|
path('accounts/', include('django.contrib.auth.urls')),
|
||||||
]
|
]
|
||||||
|
|
5
ungleichuser/ungleichuser/v6v4.py
Normal file
5
ungleichuser/ungleichuser/v6v4.py
Normal 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)
|
Loading…
Reference in a new issue