]> snippets.scripts.mit.edu Git - Scripts/git/.git/blob - django/README.md
Django: more explicit instructions, plus markdown
[Scripts/git/.git] / django / README.md
1 `/mit/__init__.py` contains some useful functionality for Django applications
2 running at MIT, particularly on the scripts.mit.edu platform
3
4 - `zephyr(msg, clas, instance, rcpt)` sends a zephyr (by shelling out to
5   zwrite).  This may be useful for debugging or logging
6 - `ScriptsRemoteUserMiddleware` and `ScriptsRemoteUserBackend` work together to
7   auto-create users from certificates on scripts.mit.edu-hosted sites. Account
8   details are automatically retrieved from LDAP.
9 - `scripts_login` is a view that tries to log users into a site using certs.
10
11 To use them, you'll probably want to symlink or copy the `mit` directory into
12 your project, add it to your apps list, and modify your middlewares and auth
13 backend appropriately. Do *not* link this (the `django` directory) into your
14 app; it's reasonably likely to break your `import django.foo` statements.
15
16 This code is descended from work on
17 [Remit](https://remit.scripts.mit.edu/trac/) and the [ASA
18 DB](https://asa.scripts.mit.edu/trac/); current and past bugs are likely to be
19 filed there.
20
21 Using certificate authentication
22 --------------------------------
23
24 1. Copy the `mit` directory into your project
25 2. Update settings.py
26    - Add `mit.ScriptsRemoteUserMiddleware` to the end of `MIDDLEWARE_CLASSES`
27    - Add `mit.ScriptsRemoteUserBackend` to the beginning of
28      `AUTHENTICATION_BACKENDS`
29 3. Add `url(r'^accounts/login/',  'mit.scripts_login',  name='login', )` to
30    your `urls.py`. This causes `@login_required` and similar mechanisms to
31    automatically redirect users to port 444 and log them in with certificates.
32