django-tequila
==============
`Tequila <http://tequila.epfl.ch/>`_ authentication for django.
Requirements
============
``django-tequila`` needs the Django 3.2+ LTS
This project also expects a fully operational `Tequila <http://tequila.epfl.ch/>`_ server.
Installation
============
pip install django-tequila
Configuration
=============
settings.py
-----------
* Add at the end of your ``MIDDLEWARE_CLASSES``::
'django_tequila.middleware.TequilaMiddleware',
* Add to ``INSTALLED_APPS``::
'django_tequila',
* Add the line::
AUTHENTICATION_BACKENDS = ('django_tequila.django_backend.TequilaBackend',)
* Set a name that will be displayed on the tequila login page::
TEQUILA_SERVICE_NAME = "django_tequila_service"
* Finally, add / customize login/logout workflow ::
LOGIN_URL = "/login"
LOGIN_REDIRECT_URL = "/"
LOGOUT_URL = '/'
LOGIN_REDIRECT_IF_NOT_ALLOWED = "/not_allowed"
LOGIN_REDIRECT_TEXT_IF_NOT_ALLOWED = "Not allowed"
urls.py
-------
* Add these lines::
from django_tequila.urls import urlpatterns as django_tequila_urlpatterns
urlpatterns += django_tequila_urlpatterns
Login/logout links
------------------
If you want the user to be redirected to a specific page after he logged/logout successfully, you have to add the 'next' parameter to your login url,
like the default Django authentication backend.
See `Django help for login-redirect-url <https://docs.djangoproject.com/en/dev/ref/settings/#login-redirect-url>`_ for more information.
Profile customization
---------------------
You may want to keep some additional information about the user.
Take a look at `this page <http://docs.djangoproject.com/en/dev/topics/auth/#storing-additional-information-about-users>`_ for more information about profile customization.
Here is an example for a profile for Django 2.0
* Create a custom User model in your `models.py` (see ./sample_app/python3-8-django-2/django_tequila_app/models.py)
* in your `settings.py`, tell django to use your model (see ./sample_app/python3-8-django-2/django_tequila_app/settings.py)::
AUTH_USER_MODEL = 'my_app.User'
TEQUILA_CUSTOM_USERNAME_ATTRIBUTE = "uniqueid"
* Update your database::
./manage.py syncdb
Site Admin customizations
-------------------------
- Add or modify your admin.py file, like ./sample_app/python3-8-django-2/django_tequila_app/admin.py
Additional tips and settings
============================
Advanced settings
-----------------
* If you need to use your personal server, change this parameter::
TEQUILA_SERVER_URL = "https://tequila.epfl.ch"
* You may want to create an inactive user when someone try to connect to your app. So you can manually control who access it.
If this is the case, add this line to `settings.py`::
TEQUILA_NEW_USER_INACTIVE = True
* You may want to add some custom allow with Tequila.
If this is the case, add this line to `settings.py`::
TEQUILA_CONFIG_ALLOW = 'categorie=shibboleth'
or, for multiple allow :
TEQUILA_CONFIG_ALLOW = 'categorie=shibboleth|categorie=epfl-old'
* You may want to add some custom paramaters with Tequila.
If this is the case, add this line to `settings.py`::
TEQUILA_CONFIG_ADDITIONAL = {'allowedorgs': 'EPFL, UNIL'}
* Everytime the user connect trought the Tequila process, he is redirected to an url
that has a 'key' parameter. For some esthetic reasons,you may want to remove this parameter,
so add this line to `settings.py`::
TEQUILA_CLEAN_URL = True
As it creates a redirect to the cleaned address and add an additional page hit, The value by default is False
* You can force a strong authentication
so add this line to `settings.py`::
TEQUILA_STRONG_AUTHENTICATION = True
Default value is False
* The only value that is truly unique is the sciper ('uniqueid' in Tequila). If your application
need a different usage, you can set to a different field (at your own risk though). You can add this line to `settings.py`::
TEQUILA_CUSTOM_USERNAME_ATTRIBUTE = 'uniqueid'
Ex. : username, email, etc.
Default value is username
* You may want to allow multiple hosts to fetch requested information.
If this is the case, add this line to `settings.py`::
TEQUILA_ALLOWED_REQUEST_HOSTS = "the host ip"
Ex. : "192.168.1.1|192.168.1.2"
Default to None
* You can allow guests to log in
so add this line to `settings.py`::
TEQUILA_ALLOW_GUESTS = True
Default value is False
Sample app
===========
You can find some django app examples in `./django-tequila/sample_app/python3-8-django-4`
Add a .env file like the `./.env.sample` and the run it with Django 4, at the root of the project ::
make build init-db
Or, for Django 1.11, prefix every make with the DOCKERFILES env set, like this ::
DOCKERFILES='-f sample_app/python3-6-django-1/docker-compose.yml' make build init-db
Then open `https://127.0.0.1/` in your browser
Use `make logs` if needed, or `make stop` to shut it down
Logging
-------
Sometimes we struggle to get the aimed result, showing some log may help :
* Add and customize as you need this logger to your settings ::
'django_tequila': {
'handlers': ['console'],
'level': 'DEBUG',
},
Debugging
---------
* The sample app can be used to debug. We use remote_pdb for this case. Set this snippet in the code ::
from remote_pdb import RemotePdb
RemotePdb('127.0.0.1', 4445).set_trace()
* Then go into the container ::
make bash
* Finally connect to the debug session with ::
telnet 127.0.0.1 4445
\(c) All rights reserved. ECOLE POLYTECHNIQUE FEDERALE DE LAUSANNE, Switzerland, VPSI
Raw data
{
"_id": null,
"home_page": "https://github.com/epfl-idevelop/django-tequila",
"name": "django-tequila",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "django,tequila,authentication",
"author": "Julien Delasoie",
"author_email": "julien.delasoie@epfl.ch",
"download_url": "https://files.pythonhosted.org/packages/e7/85/00435c3d5804a5ec9cdbefa46e0c2093655bc638bea3c42f795af01c6a9a/django-tequila-4.0.0.tar.gz",
"platform": null,
"description": "django-tequila\n==============\n\n`Tequila <http://tequila.epfl.ch/>`_ authentication for django.\n\n\nRequirements\n============\n\n``django-tequila`` needs the Django 3.2+ LTS\n\nThis project also expects a fully operational `Tequila <http://tequila.epfl.ch/>`_ server.\n\nInstallation\n============\n\n pip install django-tequila\n\nConfiguration\n=============\n\nsettings.py\n-----------\n\n* Add at the end of your ``MIDDLEWARE_CLASSES``::\n\n\t'django_tequila.middleware.TequilaMiddleware',\n\n* Add to ``INSTALLED_APPS``::\n\n\t'django_tequila',\n\n* Add the line::\n\n\tAUTHENTICATION_BACKENDS = ('django_tequila.django_backend.TequilaBackend',)\n\n* Set a name that will be displayed on the tequila login page::\n\n\tTEQUILA_SERVICE_NAME = \"django_tequila_service\"\n\n* Finally, add / customize login/logout workflow ::\n\n LOGIN_URL = \"/login\"\n LOGIN_REDIRECT_URL = \"/\"\n LOGOUT_URL = '/'\n LOGIN_REDIRECT_IF_NOT_ALLOWED = \"/not_allowed\"\n LOGIN_REDIRECT_TEXT_IF_NOT_ALLOWED = \"Not allowed\"\n\nurls.py\n-------\n\n* Add these lines::\n\n\tfrom django_tequila.urls import urlpatterns as django_tequila_urlpatterns\n\n\turlpatterns += django_tequila_urlpatterns\n\nLogin/logout links\n------------------\n\nIf you want the user to be redirected to a specific page after he logged/logout successfully, you have to add the 'next' parameter to your login url,\nlike the default Django authentication backend.\nSee `Django help for login-redirect-url <https://docs.djangoproject.com/en/dev/ref/settings/#login-redirect-url>`_ for more information.\n\n\nProfile customization\n---------------------\nYou may want to keep some additional information about the user.\nTake a look at `this page <http://docs.djangoproject.com/en/dev/topics/auth/#storing-additional-information-about-users>`_ for more information about profile customization.\n\nHere is an example for a profile for Django 2.0\n\n* Create a custom User model in your `models.py` (see ./sample_app/python3-8-django-2/django_tequila_app/models.py)\n\n* in your `settings.py`, tell django to use your model (see ./sample_app/python3-8-django-2/django_tequila_app/settings.py)::\n AUTH_USER_MODEL = 'my_app.User'\n TEQUILA_CUSTOM_USERNAME_ATTRIBUTE = \"uniqueid\"\n\n\n* Update your database::\n\n\t./manage.py syncdb\n\nSite Admin customizations\n-------------------------\n\n- Add or modify your admin.py file, like ./sample_app/python3-8-django-2/django_tequila_app/admin.py\n\n\nAdditional tips and settings\n============================\n\nAdvanced settings\n-----------------\n\n* If you need to use your personal server, change this parameter::\n\n\tTEQUILA_SERVER_URL = \"https://tequila.epfl.ch\"\n\n* You may want to create an inactive user when someone try to connect to your app. So you can manually control who access it.\n If this is the case, add this line to `settings.py`::\n\n\tTEQUILA_NEW_USER_INACTIVE = True\n\n* You may want to add some custom allow with Tequila.\n If this is the case, add this line to `settings.py`::\n\n\tTEQUILA_CONFIG_ALLOW = 'categorie=shibboleth'\n\n or, for multiple allow :\n\n\tTEQUILA_CONFIG_ALLOW = 'categorie=shibboleth|categorie=epfl-old'\n\n* You may want to add some custom paramaters with Tequila.\n If this is the case, add this line to `settings.py`::\n\n\tTEQUILA_CONFIG_ADDITIONAL = {'allowedorgs': 'EPFL, UNIL'}\n\n* Everytime the user connect trought the Tequila process, he is redirected to an url\n that has a 'key' parameter. For some esthetic reasons,you may want to remove this parameter,\n so add this line to `settings.py`::\n\n TEQUILA_CLEAN_URL = True\n\n As it creates a redirect to the cleaned address and add an additional page hit, The value by default is False\n\n* You can force a strong authentication\n so add this line to `settings.py`::\n\n TEQUILA_STRONG_AUTHENTICATION = True\n\n Default value is False\n\n* The only value that is truly unique is the sciper ('uniqueid' in Tequila). If your application\n need a different usage, you can set to a different field (at your own risk though). You can add this line to `settings.py`::\n\n TEQUILA_CUSTOM_USERNAME_ATTRIBUTE = 'uniqueid'\n\n Ex. : username, email, etc.\n\n Default value is username\n\n* You may want to allow multiple hosts to fetch requested information.\n If this is the case, add this line to `settings.py`::\n\n TEQUILA_ALLOWED_REQUEST_HOSTS = \"the host ip\"\n\n Ex. : \"192.168.1.1|192.168.1.2\"\n\n Default to None\n\n* You can allow guests to log in\n so add this line to `settings.py`::\n\n TEQUILA_ALLOW_GUESTS = True\n\n Default value is False\n\n\nSample app\n===========\n\nYou can find some django app examples in `./django-tequila/sample_app/python3-8-django-4`\nAdd a .env file like the `./.env.sample` and the run it with Django 4, at the root of the project ::\n\n make build init-db\n\n\nOr, for Django 1.11, prefix every make with the DOCKERFILES env set, like this ::\n\n DOCKERFILES='-f sample_app/python3-6-django-1/docker-compose.yml' make build init-db\n\nThen open `https://127.0.0.1/` in your browser\n\nUse `make logs` if needed, or `make stop` to shut it down\n\nLogging\n-------\n\nSometimes we struggle to get the aimed result, showing some log may help :\n\n* Add and customize as you need this logger to your settings ::\n\n 'django_tequila': {\n 'handlers': ['console'],\n 'level': 'DEBUG',\n },\n\nDebugging\n---------\n\n* The sample app can be used to debug. We use remote_pdb for this case. Set this snippet in the code ::\n\n from remote_pdb import RemotePdb\n RemotePdb('127.0.0.1', 4445).set_trace()\n\n* Then go into the container ::\n\n make bash\n\n* Finally connect to the debug session with ::\n\n telnet 127.0.0.1 4445\n\n\n\\(c) All rights reserved. ECOLE POLYTECHNIQUE FEDERALE DE LAUSANNE, Switzerland, VPSI\n\n\n",
"bugtrack_url": null,
"license": "LGPLv3",
"summary": "A Tequila authentication backend for django",
"version": "4.0.0",
"project_urls": {
"Homepage": "https://github.com/epfl-idevelop/django-tequila"
},
"split_keywords": [
"django",
"tequila",
"authentication"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "e78500435c3d5804a5ec9cdbefa46e0c2093655bc638bea3c42f795af01c6a9a",
"md5": "cb6426a3c708578e9330928a715dcf04",
"sha256": "e2dac38b1a45610b27dd55e799d0dc5c60d5730a4bd20a7d4035fff6ae52869f"
},
"downloads": -1,
"filename": "django-tequila-4.0.0.tar.gz",
"has_sig": false,
"md5_digest": "cb6426a3c708578e9330928a715dcf04",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 52837,
"upload_time": "2023-05-04T15:39:45",
"upload_time_iso_8601": "2023-05-04T15:39:45.231676Z",
"url": "https://files.pythonhosted.org/packages/e7/85/00435c3d5804a5ec9cdbefa46e0c2093655bc638bea3c42f795af01c6a9a/django-tequila-4.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-05-04 15:39:45",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "epfl-idevelop",
"github_project": "django-tequila",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "django-tequila"
}