stormpath / stormpath-django

Django plugin for Stormpath
Apache License 2.0
38 stars 19 forks source link

Add StormpathApiBackend to support the use of API tokens in BASIC auth #61

Closed mykwillis closed 8 years ago

mykwillis commented 9 years ago

The StormpathBackend class doesn't work with API key authentication that is passed in the Auth header for BASIC authentication (it only works with username/password pairs). I created this StormpathApiBackend class that does support that scenario.

StormpathApiBackend behaves just like StormpathBackend in other respects, e.g., it sets up the User object properly, creating it if it doesn't exist in the Django DB.

To use this, one needs to add another entry to the AUTHENTICATION_BACKENDS in settings.py. This being done, end users can authenticate using either username/password or api token.

AUTHENTICATION_BACKENDS = (
    'django_stormpath.backends.StormpathBackend',
    'django_stormpath.backends.StormpathApiBackend',
)
rdegges commented 8 years ago

Thank you for this PR. I'm going to reject this because we're going to be implementing this differently going forward. We're going to support a similar setup to our other libraries: we'll have various types of 'authentication' backends, which support basic auth and oauth2. We have generated some standard naming conventions / practices for this over the last year, which we'll incorporate into this project =)