Skip to main content

A Python Django package for user accounts and authentication.

Project description

# SlothAuth

SlothAuth is a Django app for adding user authentication and accounts with the follow features:

- Signup
- Login
- Logout
- Passwordless Authentication
- Passwordless Login via Email
- Add Password to Passwordless Account
- User Impersonation for Admins
- Password Reset
- Change email

Current SlothAuth has been tested with Django 1.9.x

### Credit

SlothAuth was authored by Chris Del Guercio and Shane Zilinskas

### Installation

```
pip install slothauth
```

### Quick Start

1) Add slothauth to your INSTALLED_APPS in your project's settings.py file:
```
INSTALLED_APPS += [
'slothauth',
]
```

2) Add the following to your Django projects urls.py file:
```
import slothauth.urls as slothauth_urls

urlpatterns = [
### your other urls here ###
url(r'^', include(slothauth_urls)),
]
```

Import include with:
```
from django.conf.urls import include
```

3) Add the Passwordless User middleware to your settings.py file:
```
MIDDLEWARE_CLASSES = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'slothauth.middleware.PasswordlessUserMiddleware',
'slothauth.middleware.OneTimeAuthenticationKeyMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
```

4) Add the SlothAuth Authentication Backend to your settings.py file:
```
AUTHENTICATION_BACKENDS = [
'slothauth.backends.PasswordlessAuthentication',
'django.contrib.auth.backends.ModelBackend',
]
```

5) Create a subclass of SlothAuthBaseUser in any of your project's model files:
```
from slothauth.models import SlothAuthBaseUser

class User(SlothAuthBaseUser):
# add custom fields here, or just put 'pass'
```

6) Make sure that your AUTH_USER_MODEL setting is set to your subclass of SlothAuthBaseUser:
```
AUTH_USER_MODEL = 'your_app.User'
```

7) Run the SlothAuth migration
```
python manage.py migrate slothauth
```

8) (Optional) Add the Impersonate Middleware to your settings.py file:
```
MIDDLEWARE_CLASSES += [
'slothauth.middleware.ImpersonateMiddleware',
]
```

9) Set up email in your settings.py file. You can set up a gmail account to use for testing as long as you turn
"Allow less secure apps" at https://myaccount.google.com/security#connectedapps to "ON". If it still doesn't work, try
visiting https://accounts.google.com/DisplayUnlockCaptcha. It should fix it within 15 minutes. A lot of times, Gmail
will continuously ban your account and you have to keep visiting that url to unban yourself.
```
EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_HOST_USER = 'your_email@gmail.com'
EMAIL_HOST_PASSWORD = 'your_password'
DEFAULT_FROM_EMAIL = 'your_email@gmail.com'

ACCOUNT_EMAIL_DOMAIN = 'example.com'
ACCOUNT_EMAIL_FROM = 'example@example.com'
ACCOUNT_EMAIL_PASSWORD_RESET_SUBJECT = 'Password Reset'
ACCOUNT_EMAIL_PASSWORDLESS_LOGIN_SUBJECT = 'Your Login Link'
```

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

slothauth-0.3.tar.gz (38.8 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page