Git Product home page Git Product logo

django-browserid's Introduction

Persona is Shutting Down

Mozilla has announced that Persona will be shutting down November 2016. django-browserid relies on the Persona service and will stop functioning properly once Persona is shut down. While it is possible to self-host Persona and configure django-browserid to rely on your own instance, this is difficult and not recommended. See the wiki page linked above for recommended alternatives to Persona for authentication.

django-browserid

TravisCI

django-browserid is a library that integrates BrowserID authentication into Django.

Supported versions include Python 2.7, 3.4, and onward, and Django 1.8 and up. For more details, check this project's tox test suite or TravisCI.

Documentation

http://django-browserid.readthedocs.org/

Need Help?

First, check out the troubleshooting section of the documentation, which covers solutions to several common problems.

If that doesn't help, questions can be sent to the #webdev channel on irc.mozilla.org, or by email to the current maintainer.

License

This software is licensed under the Mozilla Public License v. 2.0. For more information, read the file LICENSE.

django-browserid's People

Contributors

abompard avatar almet avatar benadida avatar edwardabraham avatar ericholscher avatar fmarier avatar fpischedda avatar glogiotatidis avatar graingert avatar groovecoder avatar kumar303 avatar meehow avatar mounirmesselmeni avatar niran avatar ozten avatar paulosman avatar peterbe avatar ptgolden avatar richardmansfield avatar robhudson avatar rossbruniges avatar seocam avatar shaib avatar tallowen avatar tkrajina avatar tofumatt avatar toolness avatar tuxcanfly avatar willkg avatar wraithan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

django-browserid's Issues

Logout button code won't work

So the code for adding a logout button to a page won't work, because you get infinite redirects from include.js if you include it after the user has logged in (It'll try to login again).

Instead we could add a URL parameter like we do for failed logins that the JS can look for and trigger a logout with.

Add notes about SESSION_COOKIE_SECURE and cache issues to troubleshooting

There's two more common error cases that deserve some mention on the troubleshooting page:

  1. If SESSION_COOKIE_SECURE is set to true on a local instance that isn't running HTTPS, when you attempt to log in nothing will happen because the cookie isn't sent over an http connection. Although this is a general auth problem, it happens often enough that we should mention it here.
  2. If sessions are stored in the cache (as they often are in playdoh projects that use this and django-session-csrf) and you don't have a cache configured locally, login will fail silently. Again, it's a general problem that comes up often enough that it deserves mention.

SITE_URL should support multiple domains

Django apps can run under multiple domain names; there is no way currently for SITE_URL to support sites that use multiple domain names.

One option is to allow SITE_URL to be a callable. I can't think of any major cons except that at a basic level it doesn't handle sites that use the Django sites framework (which typically, from what I can tell from the docs, get the current domain from the request). It'd be nice if we could either provide the current request as an argument to the SITE_URL callable, or just support the sites framework by default if it is installed.

Should return a failure rather than just log the error

Currently if a verification failure occurs it is just logged

log.error('BrowserID verification failure. Response: %r '
          'Audience: %r' % (result, audience))
log.error("BID assert: %r" % assertion)

There should be an option to return an error page

Cannot login on page after login fails

If login fails, the user is redirected to a page with the bid_login_failed parameter. If the user tries to login again on this page, it will always fail because the JS code looks for that parameter and cancels if it finds it, even if the login is user-triggered.

Creating User Accounts in README has errors

The Creating User Accounts section explains how to do custom authentication and user creation.

The first line of source code

from django_browserid.auth import get_audience, verify

does not work as these are methods on a class, not functions of django_browserid.auth.

% string operator (soon to be deprecated) is used throughout

it is advised when Python string formatting to use the str.format() method, because the % string operator will soon be deprecated.

However replacing all instances of the % string operator with str.format() will drop support for Python 2.5.

Python 2.5 is not supported in Django 1.4+ or Django dev

no login popup for firefox or IE (but works in chrome)

I'm trying to add browserid authentication to a site I'm creating using django-browserid.

The login button I created following the documentation works fine in chrome, the popup shows up and I'm able to login, however when I click the login button using either firefox or IE nothing happens. I'm not sure how to go about debugging this problem.

The site is at https://database.randonneurs.bc.ca

Any pointers about how to start debugging would be great, thanks!
-ryan

Issue signals on signup/login.

Signup/login signals are very useful for analytics, among other purposes. It would be nice if we could just listen to a signal rather than override the entire functions to do that.

Fix binding in browserid.js

If the user includes browserid.js above the embedded form in their site, the click handler won't bind properly. We should be using on to bind to the body and handle the event when it bubbles up.

Update setup.rst to add redirect_field_name example

django_browserid looks for redirect_field_name in POST data, but it is not documented anywhere.

It will save some people's time if it is documented. For example, use a form like:

    <a id="browserid" href="#">'Log in'</a>
    <form method="POST" action="{% url 'browserid_verify' %}">
        <input type="hidden" name="next" id="id_next" value="{{ next }}" />
        {% csrf_token %}
        {{ browserid_form.as_p }}
    </form>

with next passed from your view.

Add ability to add a second step on first login.

Many sites will require a more human friendly username for all users. My strawman is to have a new setting:

BROWSERID_ACTIVATE_USER = False

When set to False, we leave user.is_active = False.

Then my verify view can check if user and not user.is_active and present a form to request a username and whatever else may be required by the specific site.

DeprecationWarning in Django 1.4

I have yet to be able to test it, but from mozilla/playdoh#117 it seems that the auth backend for django-browserid causes a DeprecationWarning to be raised in django 1.4.

/home/vagrant/project/vendor/lib/python/django/contrib/auth/init.py:26: DeprecationWarning: Authentication backends without a supports_inactive_user attribute are deprecated. Please define it in .
DeprecationWarning)
[21/Jun/2012 08:03:21] "POST /en-US/browserid/browserid/verify/ HTTP/1.1" 302 0
[21/Jun/2012 08:03:21] "GET / HTTP/1.1" 301 0

setup.py script does not install all neccessary folders

newton % sudo python setup.py install
newton % l /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django_browserid
total 152
drwxr-xr-x 3 root wheel 102B Jan 26 12:08 static
-rw-r--r-- 1 root wheel 364B Jan 26 12:07 init.py
-rw-r--r-- 1 root wheel 487B Jan 26 12:07 signals.py
-rw-r--r-- 1 root wheel 598B Jan 26 12:07 urls.py
drwxr-xr-x 20 root wheel 680B Jan 26 12:08 tests
-rw-r--r-- 1 root wheel 807B Jan 26 12:07 forms.py
-rw-r--r-- 1 root wheel 2.8K Jan 26 12:07 views.py
-rw-r--r-- 1 root wheel 3.5K Jan 26 12:07 context_processors.py
-rw-r--r-- 1 root wheel 3.7K Jan 26 12:07 base.py
-rw-r--r-- 1 root wheel 4.5K Jan 26 12:07 auth.py

I believe the templatetags folder is missing there.

Smartly Handle Service issues

Currently, if Persona is unavailable, we just throw a timeout error from Requests. It'd be nicer if we wrapped that and other possible errors in a BrowserIDError-type thing, and have our default view handle that smartly.

This may also be related to #57 depending on how PyBrowserID handles errors.

SSLHandshakeError at /browserid/verify/

Using the latest django-browserid and the latest httplib2, I see the following error:

SSLHandshakeError at /browserid/verify/

[Errno 1] _ssl.c:480: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed

The issue is the root GeoTrust cert isn't in httplib2's ca_cert file and/or chained certs.

There are a couple of ways to fix this:

  • Use a custome ca_certs (I haven't test this to be true) which includes GeoTrust
  • Use httplib2 version 0.6 and remove 0.7 keywords from django-browserid
  • Add disable_ssl_certificate_validation=False config to django-browserid (weak sauce, tested works)

We're exploring fixing this at the browserid.org level also.

Document CSP whitelist domains

To use BrowserID with CSP you need to whitelist https://browserid.org/ in two places*.

CSP_SCRIPT_SRC = ("'self'", 'https://browserid.org',)
CSP_FRAME_SRC = ("'self'", 'https://browserid.org',)

Or in the default-src. Though some people report that it works without the CSP_FRAME_SRC

Httplib2 problems

Hi,

I've been having problems using django-browserid, and they all seem to come from Httplib2.

Yesterday, it was the fact that the CA which authorised browserid.org is not included in Httplib2's set of default certificates. Today, I saw the option to specify the certificates file, and progressed past that, only to find that Httplib2 rejects the certificate as not belonging to the site (it has common-name="www.browserid.org").

My workaround is in my fork, in a branch named 'urllib'.

pip install fails after commit 05cb0564152ed613715c3cffbe08dec8fbe8334f

In commit 05cb056, it looks like two lines were added to django_browserid/init.py:

 from django_browserid.auth import BrowserIDBackend
 from django_browserid.base import get_audience, verify

Because of these two lines both of the following fail:

pip install git+git://github.com/mozilla/django-browserid.git#egg=django_browserid

mkdir t
cd t
git clone git://github.com/mozilla/django-browserid.git
cd django-browserid
python setup.py install

In both cases, I get the following error message:
ImportError: Settings cannot be imported, because environment variable DJANGO_SETTINGS_MODULE is undefined.

setup.py imports django_browserid/init.py to get the version number, but at setup time, the django environment is not available. These two imports should be removed from init.py or it should not be imported into the setup.py.

SSLError when verify server cert of https://browserid.org

Not sure if this is the correct project to file this.

If viewed from the address bar, server cert of https://browserid.org chains up to GeoTrust Global CA, while openssl s_client -connect -showcerts browserid.org:443 shows the cert chains up to Equifax Secure Certificate Authority.

Setting BROWSERID_CACERT_FILE = 'Equifax_Secure_Certificate_Authority.cer' (download) fixes the SSLError for me.

data-return-to is not respected

I have a case where I need to make sure the user goes back to the current page, rather than my LOGIN_REDIRECT_URL so I am trying to use returnTo via navigator.id.request arguments in the docs.

What I am seeing is it takes me to my LOGIN_REDIRECT_URL anyway. I'd like it to take me to my data-return-to instead. Either that, or I need another mechanism for returning to a specific page.

UnicodeEncodeError if verify extra_params contain unicode

django_browserid.verify passes extra_params through urllib.urlencode, which breaks on unicode strings as it passes them through str. Since it looks like requests handles this automagically anyway, we should not pass it through and add a test for unicode params to ensure it handles them properly.

Make setup and configuration less painful

Let's face it: Setting up django-browserid has lots and lots of annoying steps and has lots and lots of annoying ways to mess up. This issue exists to track the ways we can make setup less painful.

A phishing attack is possible where a fake browserID dialogue is launched

A phishing attack is possible where a fake browserID dialogue is launched.

To allow the user to distinguish between a real browserID auth dialogue and a phishing dialogue do what many banks and sites like Yahoo do and allow the user to set a secret string or image for browserID to respond with.

This is only needed for the shim and when a site is not a browserID auth provider/primary

Update README to mention jQuery and clarify gracefully_degrade

If users are using the included JS, they will need to know that jQuery is required to use it (alternatively, we remove the jquery dependency if possible).

In addition, the {% url gracefully_degrade %} placeholder is misleading as it currently stands. Either we need to explain better that it is a place for a fallback URL to a normal, non-JS login, or replace it with something better.

Firefox 15 caches assertions, which can result in an infinite loop

If BROWSERID_CREATE_USER is False, a valid assertion with no associated user can result in an infinite loop in Firefox 15.

browserid.js watches navigator.id for the "onlogin" callback. After navigator.id.request() returns with a valid assertion, Firefox 15 caches the result, and calls the onlogin callback, which asks Django to validate the email address. If that email isn't associated with a user, the call is redirected to the failure url. If the failure URL returns a page which includes browserid.js (which is reasonable, if we want to give people a second chance to log in), navigator.id.watch will immediately fire "onlogin" again with the cached assertion, asking Django to verify it again, etc.

Fixing this is complicated by the fact that the API does not expose whether verification fails because of an invalid assertion, and other browsers don't cache the assertion (so we can't just ignore the first firing of "onlogin").

The only workaround I can figure out right now is to always have the failure URL call "navigator.id.logout()" /before/ browserid.js executes.

Emails should always be lowercased.

I'm not sure if browserid.org always returns lowercase emails, but I'm pretty sure it won't hurt if the code also lowercases emails. If this is not done, users might type their email address with uppercase letters and create duplicate emails in the various services they use, particularly ones with two signon systems.

Default JS include should hide login button until login event is bound

@jsocol pointed out that if JS loads slowly, users may attempt to click the login button before the click event for launching the BrowserID popup is bound.

MDN handles this by hiding the button with CSS and showing it after the event is bound. Our default JS and code example should do something similar to encourage good behavior.

Integrate with PyBrowserID

hey-hi!

We've been working with @rfk on PyBrowserID (http://github.com/mozilla/PyBrowserID), and it seems that it could be great to integrate the two projects.

It would allow, into other things, to do verifications locally (rather than having to call a remote server), or to offload the crypto work to specialized workers (we are using this for our tokenserver at mozilla-services http://docs.services.mozilla.com/token/)

Into other things, here is what I'm proposing (which is partially implemented in my fork ):

  • Adding some settings so that you can select the verifier you want to use. the choice would be between "local", "remote" and "custom" (which could be useful in some specialized cases).
  • replacing the use of get_audience with the one specified in PyBrowserID, forcing users to define what's the intended audience they want (could be done using wildcards if needed).

However, it's important to notde that PyBrowserID stills need some love wrt to requests and certificates to cover all the cases you're covering. I've talked with @Osmose about that and he'll have a look at it prolly later this week.

Any thoughs?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.