README.md 3.43 KB
Newer Older
David Seaward's avatar
David Seaward committed
1 2
Puri.st account manager
=======================
3 4 5 6 7 8 9 10 11 12 13

A Django site for account registration and management for Puri.st
services. In particular, user registration creates an LDAP user,
which is used for authentication by other services.

Expects to be hosted at <https://example.com/account/>

Prerequisites
-------------

* Debian 8
David Seaward's avatar
David Seaward committed
14
* Python 3.4 / 3.5
15 16
* Django 1.10
* Debian packages:
David Seaward's avatar
David Seaward committed
17 18 19 20
    * `libsasl2-dev`
    * `libldap2-dev`
    * `libssl-dev`
    * `python3-dev`
21 22 23 24 25 26 27
* Python/Django packages: see `requirements.txt`

Other versions may work but are untested.

Installation
------------

David Seaward's avatar
David Seaward committed
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
* Create project folder (for example `/opt/purist_account/`)
* Copy project into project folder
* Install Debian prerequisites (`apt install libsasl2-dev` ...)
* Set up virtualenv
    * Create virtualenv in project folder (`virtualenv . -p python3`)
    * Activate virtualenv (`/opt/purist_account/bin/activate.py`)
    * Install Python packages (`pip install -r requirements.txt`)
* Complete Django settings
    * Copy `purist_account/settings_local.txt` as `settings_local.py`
    * Fill in settings values
* Run `./manage.py migrate --settings=purist_account.settings_local`
* Run `./manage.py createsuperuser --settings=purist_account.settings_local`
    * When prompted, enter the credentials of your LDAP superuser / account manager
* Hook up Django site to webserver (i.e. Apache HTTPD, Nginx...)
* Hook up system service (i.e. systemd, supervisord...) to runserver directive (`manage.py runserver --settings=purist_account.settings_local`)
43 44 45

For more options and details see <https://docs.djangoproject.com/en/1.10/#the-development-process>

David Seaward's avatar
David Seaward committed
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
Migrations
----------

This is a workaround for [#155](https://github.com/django-ldapdb/django-ldapdb/issues/115).

If you need to make a new migration:

* Open `ldapregister.0003_ldapgroup_ldapperson`
* Switch `LdapGroup.cn` and `LdapPerson.uid` from non-primary to primary
* Run `makemigrations`
* Switch `LdapGroup.cn` and `LdapPerson.uid` back to non-primary
* If you have just added a new LDAP table, switch `NewTable.key` to non-primary too 
* Run `migrate`

You only need to do this when creating new migrations (`makemigrations`) not when running
existing migrations (`migrate`).

63 64 65
Usage
-----

David Seaward's avatar
David Seaward committed
66 67 68 69
* Start Django site
    * Start with system service, or
    * `./manage.py runserver --settings=purist_account.settings_local`
* Visit <https://example.com> and follow login and/or register links
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90

License
-------

SPDX-License-Identifier: GPL-3.0+

    Puri.st account manager, a Django site for account registration and management
    Copyright (C) 2017 Purism and contributors

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
91 92 93 94 95

Also includes code portions from:

* https://github.com/yourcelf/django-registration-defaults (Copyright 2010 Charlie DeTar, Expat/MIT)
* https://github.com/asyd/pyldap_orm/blob/master/pyldap_orm/controls.py (Copyright 2016 Bruno Bonfils, Apache 2.0)