{ "info": { "author": "Francois Voron", "author_email": "francois.voron@nereo.fr", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Environment :: Web Environment", "Framework :: Django", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3", "Topic :: Internet :: WWW/HTTP" ], "description": "Django CAS NG\n=============\n\n.. image:: https://travis-ci.org/mingchen/django-cas-ng.svg?branch=master\n :target: https://travis-ci.org/mingchen/django-cas-ng\n\n\n``django-cas-ng`` is Central Authentication Service (CAS) client implementation.\nThis project inherits from `django-cas`_ (which has not been updated since\nApril 2013). The NG stands for \"next generation\". Our fork will include\nbugfixes and new features contributed by the community.\n\n\nFeatures\n--------\n\n- Supports CAS_ versions 1.0, 2.0 and 3.0.\n- `Support Single Sign Out`_\n- Can fetch Proxy Granting Ticket\n- Supports Django 1.5, 1.6, 1.7 and 1.8 with `User custom model`_\n- Supports Python 2.7, 3.x\n\n\nInstallation\n------------\n\nInstall with `pip`_::\n\n pip install django-cas-ng\n\n\nInstall the latest code::\n\n pip install https://github.com/mingchen/django-cas-ng/archive/master.zip\n\n\nInstall from source code::\n\n python setup.py install\n\n\nSettings\n--------\n\nNow add it to the middleware, authentication backends and installed apps in your settings.\nMake sure you also have the authentication middleware installed.\nHere's an example::\n\n INSTALLED_APPS = (\n 'django.contrib.admin',\n 'django.contrib.auth',\n 'django.contrib.contenttypes',\n 'django.contrib.sessions',\n 'django.contrib.messages',\n 'django.contrib.staticfiles',\n 'django_cas_ng',\n ...\n )\n\n MIDDLEWARE_CLASSES = (\n 'django.middleware.common.CommonMiddleware',\n 'django.contrib.sessions.middleware.SessionMiddleware',\n 'django.contrib.auth.middleware.AuthenticationMiddleware',\n ...\n )\n\n AUTHENTICATION_BACKENDS = (\n 'django.contrib.auth.backends.ModelBackend',\n 'django_cas_ng.backends.CASBackend',\n )\n\nSet the following required setting in ``settings.py``:\n\n* ``CAS_SERVER_URL``: This is the only setting you must explicitly define.\n Set it to the base URL of your CAS source (e.g. https://account.example.com/cas/).\n\nOptional settings include:\n\n* ``CAS_ADMIN_PREFIX``: The URL prefix of the Django administration site.\n If undefined, the CAS middleware will check the view being rendered to\n see if it lives in ``django.contrib.admin.views``.\n* ``CAS_CREATE_USER``: Create a user when the CAS authentication is successful.\n The default is ``True``.\n* ``CAS_LOGIN_MSG``: Welcome message send via the messages framework upon\n successful authentication. Take the user login as formatting argument.\n The default is ``\"Login succeeded. Welcome, %s.\"`` or some translation of it\n if you have enabled django internationalization (``USE_I18N = True``)\n You cas disable it by setting this parametter to ``None``\n* ``CAS_LOGGED_MSG``: Welcome message send via the messages framework upon\n authentication attempt if the user is already authenticated.\n Take the user login as formatting argument.\n The default is ``\"You are logged in as %s.\"`` or some translation of it\n if you have enabled django internationalization (``USE_I18N = True``)\n You cas disable it by setting this parametter to ``None``\n* ``CAS_EXTRA_LOGIN_PARAMS``: Extra URL parameters to add to the login URL\n when redirecting the user. Example::\n\n CAS_EXTRA_LOGIN_PARAMS = {'renew': true}\n\n If you need these parameters to be dynamic, then we recommend to implement\n a wrapper for our default login view (the same can be done in case of the\n logout view). See an example in the section below.\n\n* ``CAS_RENEW``: whether pass ``renew`` parameter on login and verification\n of ticket to enforce that the login is made with a fresh username and password\n verification in the CAS server. Default is ``False``.\n* ``CAS_IGNORE_REFERER``: If ``True``, logging out of the application will\n always send the user to the URL specified by ``CAS_REDIRECT_URL``.\n* ``CAS_LOGOUT_COMPLETELY``: If ``False``, logging out of the application\n won't log the user out of CAS as well.\n* ``CAS_REDIRECT_URL``: Where to send a user after logging in or out if\n there is no referrer and no next page set. This setting also accepts named\n URL patterns. Default is ``/``.\n* ``CAS_RETRY_LOGIN``: If ``True`` and an unknown or invalid ticket is\n received, the user is redirected back to the login page.\n* ``CAS_VERSION``: The CAS protocol version to use. ``'1'`` ``'2'`` ``'3'`` and ``'CAS_2_SAML_1_0'`` are\n supported, with ``'2'`` being the default.\n* ``CAS_USERNAME_ATTRIBUTE``: The CAS user name attribute from response. The default is ``uid``.\n* ``CAS_PROXY_CALLBACK``: The full url to the callback view if you want to\n retrive a Proxy Granting Ticket\n* ``CAS_FORCE_CHANGE_USERNAME_CASE``: If ``lower``, usernames returned from CAS are lowercased before\n we check whether their account already exists. Allows user `Joe` to log in to CAS either as\n `joe` or `JOE` without duplicate accounts being created by Django (since Django allows\n case-sensitive duplicates). If ``upper``, the submitted username will be uppercased. Default is ``False``.\n\nMake sure your project knows how to log users in and out by adding these to\nyour URL mappings::\n\n import django_cas_ng\n\n url(r'^accounts/login$', django_cas_ng.views.login, name='cas_ng_login'),\n url(r'^accounts/logout$', django_cas_ng.views.logout, name='cas_ng_logout'),\n\nYou should also add an URL mapping for the ``CAS_PROXY_CALLBACK`` settings::\n\n url(r'^accounts/callback$', django_cas_ng.views.callback, name='cas_ng_proxy_callback'),\n\n\nRun ``./manage.py syncdb`` to create Single Sign On and Proxy Granting Ticket tables.\nOn update you can just delete the ``django_cas_ng_sessionticket`` table and the\n``django_cas_ng_proxygrantingticket`` before calling ``./manage.py syncdb``.\n\nConsider running the command ``./manage.py django_cas_ng_clean_sessions`` on a regular basis\nright after the command ``./manage.py clearsessions`` cf `clearsessions`_.\nIt could be a good idea to put it in the crontab.\n\nUsers should now be able to log into your site using CAS.\n\nView-wrappers example\n---------------------\n\nThe ``settings.CAS_EXTRA_LOGIN_PARAMS`` allows you to define a static\ndictionary of extra parameters to be passed on to the CAS login page. But what\nif you want this dictionary to be dynamic (e.g. based on user session)?\n\nOur current advice is to implement simple wrappers for our default views, like\nthese ones:\n\n.. code-block:: python\n\n from django_cas_ng import views as baseviews\n\n @csrf_exempt\n def login(request, **kwargs):\n return _add_locale(request, baseviews.login(request, **kwargs))\n\n\n def logout(request, **kwargs):\n return _add_locale(request, baseviews.logout(request, **kwargs))\n\n\n def _add_locale(request, response):\n \"\"\"If the given HttpResponse is a redirect to CAS, then add the proper\n `locale` parameter to it (and return the modified response). If not, simply\n return the original response.\"\"\"\n\n if (\n isinstance(response, HttpResponseRedirect)\n and response['Location'].startswith(settings.CAS_SERVER_URL)\n ):\n from ourapp.some_module import get_currently_used_language\n url = response['Location']\n url += '&' if '?' in url else '&'\n url += \"locale=%s\" % get_currently_used_language(request)\n response['Location'] = url\n return response\n\nCustom backends\n---------------\n\nThe ``CASBackend`` class is heavily inspired from Django's own\n``RemoteUserBackend`` and allows for some configurability through subclassing\nif you need more control than django-cas-ng's settings provide. For instance,\nhere is an example backend that only allows some users to login through CAS:\n\n.. code-block:: python\n\n from django_cas_ng.backends import CASBackend\n\n class MyCASBackend(CASBackend):\n def user_can_authenticate(self, user):\n if user.has_permission('can_cas_login'):\n return True\n return False\n\nIf you need more control over the authentication mechanism of your project than\ndjango-cas-ng's settings provide, you can create your own authentication\nbackend that inherits from ``django_cas_ng.backends.CASBackend`` and override\nthese attributes or methods:\n\n**CASBackend.clean_username(username)**\n\nPerforms any cleaning on the ``username`` prior to using it to get or create a\n``User`` object. Returns the cleaned username. The default implementations\nchanges the case according to the value of ``CAS_FORCE_CHANGE_USERNAME_CASE``.\n\n**CASBackend.user_can_authenticate(user)**\n\nReturns whether the user is allowed to authenticate. For consistency with\nDjango's own behavior, django-cas-ng will allow all users to authenticate\nthrough CAS on Django versions lower than 1.10; starting with Django 1.10\nhowever, django-cas-ng will prevent users with ``is_active=False`` from\nauthenticating.\n\n**CASBackend.configure_user(user)**\n\nConfigures a newly created user. This method is called immediately after a new\nuser is created, and can be used to perform custom setup actions. Returns the\nuser object.\n\nSignals\n-------\n\ndjango_cas_ng.signals.cas_user_authenticated\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\nSent on successful authentication, the ``CASBackend`` will fire the ``cas_user_authenticated`` signal.\n\n**Arguments sent with this signal**\n\n**sender**\n The authentication backend instance that authenticated the user.\n\n**user**\n The user instance that was just authenticated.\n\n**created**\n Boolean as to whether the user was just created.\n\n**attributes**\n Attributes returned during by the CAS during authentication.\n\n**ticket**\n The ticket used to authenticate the user with the CAS.\n\n**service**\n The service used to authenticate the user with the CAS.\n\n\ndjango_cas_ng.signals.cas_user_logout\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\nSent on user logout. Will be fired over manual logout or logout via CAS SingleLogOut query.\n\n**Arguments sent with this signal**\n\n**sender**\n ``manual`` if manual logout, ``slo`` on SingleLogOut\n\n**user**\n The user instance that is logged out.\n\n**session**\n The current session we are loging out.\n\n**ticket**\n The ticket used to authenticate the user with the CAS. (if found, else value if set to ``None``)\n\n\nProxy Granting Ticket\n---------------------\n\nIf you want your application to be able to issue Proxy Ticket to authenticate against some other CAS application,\nsetup the CAS_PROXY_CALLBACK parameter.\nAllow on the CAS config django_cas_ng to act as a Proxy application.\nThen after a user has logged in using the CAS, you can retrieve a Proxy Ticket as follow:\n\n from django_cas_ng.models import ProxyGrantingTicket\n\n def my_pretty_view(request, ...):\n proxy_ticket = ProxyGrantingTicket.retrieve_pt(request, service)\n\nwhere ``service`` is the service url for which you want a proxy ticket.\n\n\nInternationalization\n--------------------\n\nYou can contribute to the translation of welcome messages by running ``django-admin makemessages -l lang_code``\ninside of the django_cas_ng directory. Where ``lang_code`` is the language code for which you want to submit a\ntranslation. Then open the file ``django_cas_ng/locale/lang_code/LC_MESSAGES/django.po`` with a gettex translations\neditor (for example https://poedit.net/). Translate and save the file.\nThink to add ``django_cas_ng/locale/lang_code/LC_MESSAGES/django.po`` to repo. Please do not add ``django_cas_ng/locale/lang_code/LC_MESSAGES/django.mo`` to repo since .mo file can be generated by .po file.\n\n\nTesting\n-------\n\nEvery code commit triggers a **travis-ci** build. checkout current build status at https://travis-ci.org/mingchen/django-cas-ng\n\nTesting is managed by ``pytest`` and ``tox``.\nBefore run install, you need install required packages for testing::\n\n pip install -r requirements-dev.txt\n\n\nTo run testing on locally::\n\n py.test\n\n\nTo run all testing on all enviroments locally::\n\n tox\n\n\nContribution\n------------\n\nContributions are welcome!\n\nIf you would like to contribute this project.\nPlease feel free to fork and send pull request.\nPlease make sure tests are passed.\nAlso welcome to add your name to **Credits** section of this document.\n\nNew code should follow both `PEP8`_ and the `Django coding style`_.\n\n\nCredits\n-------\n\n* `django-cas`_\n* `Stefan Horomnea`_\n* `Piotr Buli\u0144ski`_\n* `Piper Merriam`_\n* `Nathan Brown`_\n* `Jason Brownbridge`_\n* `Bryce Groff`_\n* `Jeffrey P Gill`_\n* `timkung1`_\n* `Domingo Yeray Rodr\u00edguez Mart\u00edn`_\n* `Rayco Abad-Mart\u00edn`_\n* `\u00c9douard Lopez`_\n* `Guillaume Vincent`_\n* `Wojciech Rygielski`_\n* `Valentin Samir`_\n* `Alexander Kavanaugh`_\n\nReferences\n----------\n\n* `django-cas`_\n* `CAS protocol`_\n* `Jasig CAS server`_\n\n.. _CAS: https://www.apereo.org/cas\n.. _CAS protocol: https://www.apereo.org/cas/protocol\n.. _Support Single Sign Out: https://wiki.jasig.org/display/casum/single+sign+out\n.. _django-cas: https://bitbucket.org/cpcc/django-cas\n.. _clearsessions: https://docs.djangoproject.com/en/1.8/topics/http/sessions/#clearing-the-session-store\n.. _pip: http://www.pip-installer.org/\n.. _PEP8: http://www.python.org/dev/peps/pep-0008\n.. _Django coding style: https://docs.djangoproject.com/en/dev/internals/contributing/writing-code/coding-style\n.. _User custom model: https://docs.djangoproject.com/en/1.5/topics/auth/customizing/\n.. _Jasig CAS server: http://jasig.github.io/cas\n.. _Piotr Buli\u0144ski: https://github.com/piotrbulinski\n.. _Stefan Horomnea: https://github.com/choosy\n.. _Piper Merriam: https://github.com/pipermerriam\n.. _Nathan Brown: https://github.com/tsitra\n.. _Jason Brownbridge: https://github.com/jbrownbridge\n.. _Bryce Groff: https://github.com/bgroff\n.. _Jeffrey P Gill: https://github.com/jpg18\n.. _timkung1: https://github.com/timkung1\n.. _Domingo Yeray Rodr\u00edguez Mart\u00edn: https://github.com/dyeray\n.. _Rayco Abad-Mart\u00edn: https://github.com/Rayco\n.. _\u00c9douard Lopez: https://github.com/edouard-lopez\n.. _Guillaume Vincent: https://github.com/guillaumevincent\n.. _Wojciech Rygielski: https://github.com/wrygiel\n.. _Valentin Samir: https://github.com/nitmir\n.. _Alexander Kavanaugh: https://github.com/kavdev", "description_content_type": null, "docs_url": null, "download_url": "https://github.com/Nereo/django-cas-ng/releases", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/Nereo/django-cas-ng", "keywords": "django,cas,cas2,cas3,client,sso,single sign-on,authentication,auth", "license": "BSD", "maintainer": "", "maintainer_email": "", "name": "nereo-django-cas-ng", "package_url": "https://pypi.org/project/nereo-django-cas-ng/", "platform": "", "project_url": "https://pypi.org/project/nereo-django-cas-ng/", "project_urls": { "Download": "https://github.com/Nereo/django-cas-ng/releases", "Homepage": "https://github.com/Nereo/django-cas-ng" }, "release_url": "https://pypi.org/project/nereo-django-cas-ng/4.0.2/", "requires_dist": null, "requires_python": "", "summary": "CAS 1.0/2.0 client authentication backend for Django (inherited from django-cas)", "version": "4.0.2" }, "last_serial": 2647252, "releases": { "4.0.0": [ { "comment_text": "", "digests": { "md5": "2f912e3cf28956041ff979874487c037", "sha256": "88eae1565cc44857730b52ac378d010335a1b227bdd2464af980a8e5822fbfcb" }, "downloads": -1, "filename": "nereo_django_cas_ng-4.0.0-py2-none-any.whl", "has_sig": false, "md5_digest": "2f912e3cf28956041ff979874487c037", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 24524, "upload_time": "2017-02-01T16:05:03", "url": "https://files.pythonhosted.org/packages/35/ea/529f488ac3c8fc0d2a18908679fd8042aa3cbd11752514ccad4d513e867e/nereo_django_cas_ng-4.0.0-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "2044f612b0be317213e73958b20bf460", "sha256": "14988e92da71ecb8d2e2acacab08ed63858de8f89421bc5f68f7062f71a2a193" }, "downloads": -1, "filename": "nereo-django-cas-ng-4.0.0.tar.gz", "has_sig": false, "md5_digest": "2044f612b0be317213e73958b20bf460", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15881, "upload_time": "2017-02-01T16:05:05", "url": "https://files.pythonhosted.org/packages/e3/db/e546342ab0f1b36296a9239007818a095db72b43a6beeae6485b85ef66fa/nereo-django-cas-ng-4.0.0.tar.gz" } ], "4.0.1": [ { "comment_text": "", "digests": { "md5": "1a3129d3d7ea9e4bd2a04d773f1ab520", "sha256": "8e9f772efdf700aec97c82276fb561ab26031a53dbbc91305e440845539f5834" }, "downloads": -1, "filename": "nereo-django-cas-ng-4.0.1.tar.gz", "has_sig": false, "md5_digest": "1a3129d3d7ea9e4bd2a04d773f1ab520", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15918, "upload_time": "2017-02-16T16:25:47", "url": "https://files.pythonhosted.org/packages/98/b3/e9f699b7aa1dbe40a81829535d6a6cf21090558ac72fd30d1783dfd33c69/nereo-django-cas-ng-4.0.1.tar.gz" } ], "4.0.2": [ { "comment_text": "", "digests": { "md5": "292a099195da7687e4e29244a514fb08", "sha256": "c5739a9b39c0cc33836278b8c84cc86b95049de2e9e4702554d6cf35683faac4" }, "downloads": -1, "filename": "nereo-django-cas-ng-4.0.2.tar.gz", "has_sig": false, "md5_digest": "292a099195da7687e4e29244a514fb08", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15907, "upload_time": "2017-02-16T16:32:58", "url": "https://files.pythonhosted.org/packages/21/bc/08bdd0bdf35adc142c8cbe79f3d45fee1a159ac776a7d27ba618a71eef02/nereo-django-cas-ng-4.0.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "292a099195da7687e4e29244a514fb08", "sha256": "c5739a9b39c0cc33836278b8c84cc86b95049de2e9e4702554d6cf35683faac4" }, "downloads": -1, "filename": "nereo-django-cas-ng-4.0.2.tar.gz", "has_sig": false, "md5_digest": "292a099195da7687e4e29244a514fb08", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15907, "upload_time": "2017-02-16T16:32:58", "url": "https://files.pythonhosted.org/packages/21/bc/08bdd0bdf35adc142c8cbe79f3d45fee1a159ac776a7d27ba618a71eef02/nereo-django-cas-ng-4.0.2.tar.gz" } ] }