# django-uniauth
[![travis][travis-image]][travis-url]
[![pyver][pyver-image]][pyver-url]
[![djangover][djangover-image]][djangover-url]
[![pypi][pypi-image]][pypi-url]
`django-uniauth` is an app for allowing authentication through services commonly used by universities, such as [CAS](https://www.apereo.org/projects/cas), while also permitting custom authentication schemes. This approach allows developers to leverage the user data contained within university databases, without strictly tethering themselves to those services. It also allows educational software to have a drop-in authentication solution utilizing the single-sign-on mechanisms of universities, typically CAS, to avoid requiring students to create an additional username or password.
The app was designed to replace key features of the built-in `django.contrib.auth` package. Developers may simply replace the appropriate backends and URLs and let Uniauth handle authentication entirely if they wish. However, the app is also fully customizable, and components may be swapped with compatible replacements if desired.
<p align="center">
<img src="https://s3.amazonaws.com/uniauth/documentation/Login+Page.png" />
</p>
## Features
- Supports Python 2.7, 3.5+
- Supports Django 1.11, 2.x
- Supports using a [custom User model](https://docs.djangoproject.com/en/2.1/topics/auth/customizing/#specifying-a-custom-user-model)
- Supports using email addresses as the ["username" field](https://docs.djangoproject.com/en/2.1/topics/auth/customizing/#django.contrib.auth.models.CustomUser.USERNAME_FIELD)
- Users can link multiple email addresses and use any for authentication
- Supports CAS authentication and Single Sign On
- Multiple CAS servers can be configured and users may use any for authentication
## Major Updates
- **1.2.0:** Uniauth `UserProfile` model now backreferenced from the Django `User` model via `user.uniauth_profile` instead of `user.profile`.
## Tutorials
- How to add CAS authentication with Uniauth: [link](https://medium.com/@ldgoodridge95/adding-cas-authentication-to-your-django-app-with-django-uniauth-13ff4e1e7bfa)
## Table of Contents
- [Installation](https://github.com/lgoodridge/django-uniauth#installation)
- [Email Setup](https://github.com/lgoodridge/django-uniauth#email-setup)
- [Settings](https://github.com/lgoodridge/django-uniauth#settings)
- [Users in Uniauth](https://github.com/lgoodridge/django-uniauth#users-in-uniauth)
- [Models](https://github.com/lgoodridge/django-uniauth#models)
- [Backends](https://github.com/lgoodridge/django-uniauth#backends)
- [Commands](https://github.com/lgoodridge/django-uniauth#commands)
- [Views](https://github.com/lgoodridge/django-uniauth#views)
- [Template Customization](https://github.com/lgoodridge/django-uniauth#template-customization)
- [URLs](https://github.com/lgoodridge/django-uniauth#urls)
- [User Migration](https://github.com/lgoodridge/django-uniauth#user-migration)
- [Demo Application](https://github.com/lgoodridge/django-uniauth#demo-application)
- [Acknowledgements](https://github.com/lgoodridge/django-uniauth#acknowledgements)
## Installation
Install using [pip](http://www.pip-installer.org/):
pip install django-uniauth
Add 'uniauth' to your `INSTALLED_APPS` setting:
INSTALLED_APPS = [
...
uniauth,
]
Add the desired Uniauth authentication backends. For example:
AUTHENTICATION_BACKENDS = [
'uniauth.backends.LinkedEmailBackend',
'uniauth.backends.CASBackend',
]
Include the `uniauth` URLS in your `urls.py`:
urlpatterns = [
...
path('accounts/', include('uniauth.urls', namespace='uniauth')),
]
Lastly, add your desired institution CAS server(s). For example:
python manage.py add_institution "Example Institution" https://cas.example.edu/
See the [commands section](https://github.com/lgoodridge/django-uniauth#commands) for more information regarding adding and removing institution CAS servers.
## Email Setup
Uniauth will send emails to users when necessary, such as to verify email addresses or for resetting passwords. During development, it may be sufficient to log these emails to the console - this is accomplished by adding the following to `settings.py`:
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
On production, a real email backend should be properly set up. See the docs on [setting up an SMTP backend](https://docs.djangoproject.com/en/2.1/topics/email/#smtp-backend) for more information.
## Settings
Uniauth uses the following settings from the `django.contrib.auth` package:
- [`LOGIN_URL`]( https://docs.djangoproject.com/en/2.1/ref/settings/#login-url): Determines where to redirect the user for login, particularly when using the `@login_required` decorator. Defaults to `/accounts/login/`.
- [`PASSWORD_RESET_TIMEOUT_DAYS`](https://docs.djangoproject.com/en/2.1/ref/settings/#password-reset-timeout-days): Determines how long password reset and email verification links are valid after being generated. Defaults to `3`.
The following custom settings are also used:
- `UNIAUTH_ALLOW_SHARED_EMAILS`: Whether to allow a single email address to be linked to multiple profiles. Primary email addresses (the value set in the user's `email` field) must be unique regardless. Defaults to `True`.
- `UNIAUTH_ALLOW_STANDALONE_ACCOUNTS`: Whether to allow users to log in via an Institution Account (such as via CAS) without linking it to a Uniauth profile first. If set to `False`, users will be required to create or link a profile to their Institution Accounts before being able to access views protected by the `@login_required` decorator. Defaults to `True`.
- `UNIAUTH_FROM_EMAIL`: Determines the "from" email address when Uniauth sends an email, such as for email verification or password resets. Defaults to `uniauth@example.com`.
- `UNIAUTH_LOGIN_DISPLAY_STANDARD`: Whether the email address / password form is shown on the `login` view. If `False`, the form, "Create an Account" link, and "Forgot Password" link are hidden, and POST requests for the view will be ignored. Defaults to `True`.
- `UNIAUTH_LOGIN_DISPLAY_CAS`: Whether the option to sign in via CAS is shown on the `login` view. If `True`, there must be at least one `Institution` in the database to log into. Also, at least one of `UNIAUTH_LOGIN_DISPLAY_STANDARD` or `UNIAUTH_LOGIN_DISPLAY_CAS` must be `True`. Violating either of these constraints will result in an `ImproperlyConfigured` Exception. Defaults to `True`.
- `UNIAUTH_LOGIN_REDIRECT_URL`: Where to redirect the user after logging in, if no next URL is provided. Defaults to `/`.
- `UNIAUTH_LOGOUT_REDIRECT_URL`: Where to redirect the user after logging out, if no next URL is provided. If this setting is `None`, and a next URL is not provided, the logout template is rendered instead. Defaults to `None`.
- `UNIAUTH_LOGOUT_CAS_COMPLETELY`: Whether to log the user out of CAS on logout if the user originally logged in via CAS. Defaults to `False`.
- `UNIAUTH_MAX_LINKED_EMAILS`: The maximum number of emails a user can link to their profile. If this value is less than or equal to 0, there is no limit to the number of linked emails. Defaults to 20.
- `UNIAUTH_PERFORM_RECURSIVE_MERGING`: Whether to attempt to recursively merge One-to-One fields when merging users due to linking two existing accounts together. If `False`, One-to-One fields for the user being linked in will be deleted if the primary user has a non-null value for that field. Defaults to `True`.
## Users in Uniauth
Uniauth supports any custom User model, so long as the model has `username` and `email` fields. The `email` serves as the primary identifying field within Uniauth, with the `username` being set to an arbitrary unique value to support packages that require it. Once a user's profile has been activated, other apps are free to change the `username` without disrupting Uniauth's behavior.
Users are created by either c
没有合适的资源?快使用搜索试试~ 我知道了~
PyPI 官网下载 | django-uniauth-1.2.1.tar.gz
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 186 浏览量
2022-01-10
20:33:21
上传
评论
收藏 369KB GZ 举报
温馨提示
共76个文件
py:36个
html:17个
css:6个
资源来自pypi官网。 资源全名:django-uniauth-1.2.1.tar.gz
资源推荐
资源详情
资源评论
收起资源包目录
django-uniauth-1.2.1.tar.gz (76个子文件)
django-uniauth-1.2.1
MANIFEST.in 220B
PKG-INFO 25KB
uniauth
models.py 6KB
apps.py 89B
backends.py 4KB
utils.py 6KB
templates
uniauth
password-reset.html 3KB
verification-waiting.html 1KB
password-reset-email.html 284B
verification-email.html 208B
link-to-profile.html 4KB
verification-success.html 2KB
password-reset-verify-done.html 1KB
login.html 5KB
verification-failure.html 1KB
base.html 2KB
signup.html 4KB
link-success.html 1KB
password-reset-done.html 1KB
password-reset-verify.html 4KB
logout.html 1022B
settings.html 13KB
base-site.html 455B
management
commands
remove_institution.py 1KB
__init__.py 0B
add_institution.py 2KB
migrate_cas.py 2KB
migrate_custom.py 2KB
__init__.py 0B
static
uniauth
css
fa-solid.min.css 642B
bootstrap.min.css 137KB
fa-regular.min.css 650B
theme.css 193KB
font-awesome.min.css 30KB
style.css 5KB
img
favicon.ico 15KB
fonts
glyphicons-halflings-regular.woff 23KB
fontawesome-webfont.woff 96KB
glyphicons-halflings-regular.woff2 18KB
fontawesome-webfont.woff2 75KB
js
bootstrap.min.js 49KB
jquery-3.1.1.min.js 85KB
decorators.py 770B
__init__.py 0B
migrations
0002_auto_20190707_2305.py 539B
__init__.py 0B
0001_initial.py 2KB
views.py 28KB
admin.py 228B
tokens.py 379B
urls
__init__.py 51B
all.py 1KB
cas_only.py 771B
merge.py 5KB
forms.py 9KB
django_uniauth.egg-info
PKG-INFO 25KB
requires.txt 62B
SOURCES.txt 2KB
top_level.txt 14B
dependency_links.txt 1B
tests
test_commands.py 10KB
test_utils.py 12KB
models.py 48B
utils.py 872B
test_backends.py 15KB
test_merge.py 7KB
__init__.py 0B
settings.py 3KB
test_simple.py 1KB
test_view_utils.py 7KB
urls.py 169B
test_models.py 9KB
setup.cfg 38B
setup.py 2KB
LICENSE.md 7KB
README.md 22KB
共 76 条
- 1
资源评论
挣扎的蓝藻
- 粉丝: 13w+
- 资源: 15万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 海信智能电视刷机数据 LED42K330X3D(0000) 生产用软件数据 务必确认机编一致 强制刷机 整机USB升级程序
- shujudaochuceshi
- learn-ruby.zip
- test111111111111111111
- face-detect.ipynb
- 以下是一些关于ACM(国际大学生程序设计竞赛)、NOI(全国青少年信息学奥林匹克竞赛)以及CSP(全国青少年信息学奥林匹克竞赛提
- 是一些电子设计竞赛(电赛)经验分享,包括备赛策略、项目管理、团队合作和比赛期间的注意事项
- 全能运行库修复工具DirectX Repair v4.1.0.30770
- las格式点云数据使用详解(附VS编译好的LAStools工具)
- KRPano插件一键解密大师1.4.0 (解压密码1234)
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功