diff --git a/Dockerfile b/Dockerfile index df62e93..6fffe4d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,6 +6,7 @@ RUN apk add --update --no-cache\ python3-dev\ && rm -rf /var/cache/apk/* +# FIX https://github.com/python-ldap/python-ldap/issues/432 RUN echo 'INPUT ( libldap.so )' > /usr/lib/libldap_r.so WORKDIR /usr/src/app diff --git a/README.md b/README.md index c87b24e..c65178f 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,10 @@ This service runs on [account.ungleich.ch](https://account.ungleich.ch/) and allows customers manage their ungleich account (register, edit mail & password, ...). +## v2 + +* See below ungleichuser/ + ## Todos for v2: * Rewrite/create new app Django 4.0 based (ungleichuser) @@ -30,42 +34,38 @@ python3 -m venv venv pip install -r requirements.txt `` -* Clone this repository and enter top-level directory. -* (Optional) Setup a Python virtualenv and install dependencies via pip: - - `virtualenv .venv` - - `source .venv/bin/activate` - - `pip install -r requirements.txt` - - Note: you might have to install some OS dependencies (i.e. libldap2, libsasl). -* 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 +x Allow user to register in a specific subtree +x Verify that user does not exist in another subtree +x Assign an id +- Allow password reset [via Mail?] - DB usage: for password reset? ## Parameters -LDAPSERVER +Via environment variables: -## Steps / Views +* LDAPSERVERS=".." -- White space separated list of LDAP-Servers +* ADMIN_DN="" -- we use this DN to connect to LDAP +* ADMIN_PASSWORD="" -- we use this password to connect to LDAP +* SECRET_KEY +* DEBUG +* ALLOWED_HOSTS + + +## Views ### Register view Form: [get] -* captcha? * username * password1 * password2 Post receiver: [post] -* Validation / check if human * E-Mail verification E-Mail verify: [get] @@ -75,13 +75,4 @@ E-Mail verify: [get] ### 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/ +* username or email diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 057191c..0000000 --- a/requirements.txt +++ /dev/null @@ -1,10 +0,0 @@ -django==4.0rc1 -django-auth-ldap - -# To check -django-bootstrap3 -django-filter==2.1.0 -python-decouple -ldap3 -djangorestframework -requests diff --git a/ungleichuser/requirements.txt b/ungleichuser/requirements.txt new file mode 100644 index 0000000..ee32668 --- /dev/null +++ b/ungleichuser/requirements.txt @@ -0,0 +1,11 @@ +django==4.0 +ldap3 + +#django-auth-ldap + +# To check +# django-bootstrap3 +# django-filter==2.1.0 +# python-decouple +# djangorestframework +# requests diff --git a/ungleichuser/ungleichuser/forms.py b/ungleichuser/ungleichuser/forms.py index 24b092a..476ab1d 100644 --- a/ungleichuser/ungleichuser/forms.py +++ b/ungleichuser/ungleichuser/forms.py @@ -1,4 +1,22 @@ import django.contrib.auth.forms as forms -class UngleichAuthenticationForm(forms.AuthenticationForm): - address = forms.CharField(max_length=45) +from django import forms +from django.contrib.auth.forms import UserCreationForm +from django.contrib.auth.models import User + +# class UngleichAuthenticationForm(forms.AuthenticationForm): +# address = forms.CharField(max_length=45) + +class NewUserForm(UserCreationForm): + email = forms.EmailField(required=True) + + class Meta: + model = User + fields = ("username", "email", "password1", "password2") + + def save(self, commit=True): + user = super(NewUserForm, self).save(commit=False) + user.email = self.cleaned_data['email'] + if commit: + user.save() + return user