extras.rst 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. Extras
  2. ======
  3. django-browserid comes with a few extra pieces to make development easier.
  4. They're documented below.
  5. .. _offline-development:
  6. Offline Development
  7. -------------------
  8. Because django-browsered :ref:`relies on the Persona service
  9. <persona-dependence>`, offline development is not supported by default.
  10. To work around this, django-browserid includes an auto-login system that lets
  11. you specify an email to log the user in with when they click a login button.
  12. .. warning:: Auto-login is a huge security hole as it bypasses authentication.
  13. Only use it for local development on your own computer; **never**
  14. use it on a publicly-visible machine or your live, production
  15. website.
  16. Enable auto-login
  17. ~~~~~~~~~~~~~~~~~
  18. To enable auto-login:
  19. 1. Add the ``AutoLoginBackend`` class to the ``AUTHENTICATION_BACKENDS`` setting.
  20. 2. Set :attr:`BROWSERID_AUTOLOGIN_EMAIL <django.conf.settings.BROWSERID_AUTOLOGIN_EMAIL>`
  21. to the email you want to be logged in as.
  22. 3. Set :attr:`BROWSERID_AUTOLOGIN_ENABLED <django.conf.settings.BROWSERID_AUTOLOGIN_ENABLED>`
  23. to ``True``.
  24. 4. If you are not using
  25. :py:func:`browserid_js template helper <django_browserid.helpers.browserid_js>`,
  26. you have to manually add ``browserid/autologin.js`` to your site.
  27. For example:
  28. .. code-block:: python
  29. AUTHENTICATION_BACKENDS = (
  30. 'django_browserid.auth.AutoLoginBackend',
  31. 'django_browserid.auth.BrowserIDBackend', # After auto-login.
  32. )
  33. BROWSERID_AUTOLOGIN_EMAIL = 'bob@example.com'
  34. BROWSERID_AUTOLOGIN_ENABLED = True
  35. Once these are set, any login button that uses the :doc:`JavaScript API
  36. </api/javascript>` will not attempt to show the Persona popup, and will
  37. immediately log you in with the email you set above.
  38. Disable auto-login
  39. ~~~~~~~~~~~~~~~~~~
  40. To disable auto-login:
  41. 1. Set :attr:`BROWSERID_AUTOLOGIN_ENABLED <django.conf.settings.BROWSERID_AUTOLOGIN_ENABLED>`
  42. to ``False``.
  43. 2. If you added ``browserid/autologin.js`` to your site, you must remove it.