需要用户帐户的Nexus Django应用程序的核心库

django-genomix-users的Python项目详细描述


https://badge.fury.io/py/django-genomix-users.svghttps://travis-ci.org/chopdgd/django-genomix-users.svg?branch=develophttps://codecov.io/gh/chopdgd/django-genomix-users/branch/develop/graph/badge.svgUpdatesPython 3

需要用户帐户的Nexus Django应用程序的核心库

文档

完整的文档位于https://django-genomix-users.readthedocs.io

快速启动

安装Django Genomix用户:

pip install django-genomix-users

settings.py文件中对已安装的应用程序进行以下更改:

INSTALLED_APPS=(...'django.contrib.auth','django.contrib.contenttypes','django.contrib.sessions','django.contrib.sites','django.contrib.staticfiles',...'rest_framework','rest_framework.authtoken','rest_auth','django_filters',...'django_python3_ldap',...'genomix_users',...)

添加django genomix用户的url模式:

fromgenomix_usersimporturlsasgenomix_users_urlsurlpatterns=[...url(r'^',include(genomix_users_urls,namespace='users')),...]

确保settings.py文件已设置模板静态URL设置(如下示例):

TEMPLATES=[{# See: https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-TEMPLATES-BACKEND'BACKEND':'django.template.backends.django.DjangoTemplates',# See: https://docs.djangoproject.com/en/dev/ref/settings/#template-dirs'DIRS':[os.path.join(ROOT_DIR,'templates'),os.path.join(APPS_DIR,'templates'),],'OPTIONS':{# See: https://docs.djangoproject.com/en/dev/ref/settings/#template-debug'debug':DEBUG,# See: https://docs.djangoproject.com/en/dev/ref/settings/#template-loaders# https://docs.djangoproject.com/en/dev/ref/templates/api/#loader-types'loaders':['django.template.loaders.filesystem.Loader','django.template.loaders.app_directories.Loader',],# See: https://docs.djangoproject.com/en/dev/ref/settings/#template-context-processors'context_processors':['django.template.context_processors.debug','django.template.context_processors.request','django.contrib.auth.context_processors.auth','django.template.context_processors.i18n','django.template.context_processors.media','django.template.context_processors.static','django.template.context_processors.tz','django.contrib.messages.context_processors.messages',# Your stuff: custom template context processors go here],},},]STATIC_URL='/static/'

确保settings.py文件已设置了中间件(示例如下):

MIDDLEWARE=['django.middleware.security.SecurityMiddleware','django.contrib.sessions.middleware.SessionMiddleware','django.middleware.common.CommonMiddleware','django.middleware.csrf.CsrfViewMiddleware','django.contrib.auth.middleware.AuthenticationMiddleware','django.contrib.messages.middleware.MessageMiddleware','django.middleware.clickjacking.XFrameOptionsMiddleware',]

可选设置

settings.py中关闭关联用户配置文件的创建。

CREATE_PROFILE_ON_SAVE=False

settings.py中启用身份验证以使用JSON Web令牌:

REST_USE_JWT=TrueREST_FRAMEWORK={'DEFAULT_PERMISSION_CLASSES':('rest_framework.permissions.IsAuthenticated',),'DEFAULT_AUTHENTICATION_CLASSES':('rest_framework_jwt.authentication.JSONWebTokenAuthentication','rest_framework.authentication.SessionAuthentication','rest_framework.authentication.BasicAuthentication',),}

settings.py中启用LDAP身份验证:

LDAP_AUTH_URL='ldap://chop.edu:3268'LDAP_AUTH_USE_TLS=FalseLDAP_AUTH_SEARCH_BASE='dc=chop,dc=edu'LDAP_AUTH_OBJECT_CLASS='person'LDAP_AUTH_USER_LOOKUP_FIELDS=('username',)LDAP_AUTH_USER_FIELDS={"username":"sAMAccountName","first_name":"givenName","last_name":"sn","email":"mail",}LDAP_AUTH_FORMAT_USERNAME='django_python3_ldap.utils.format_username_active_directory'LDAP_AUTH_ACTIVE_DIRECTORY_DOMAIN='chop-edu'AUTHENTICATION_BACKENDS=['django.contrib.auth.backends.ModelBackend','django_python3_ldap.auth.LDAPBackend',]

settings.py中启用LDAP用户组筛选:

LDAP_AUTH_FORMAT_SEARCH_FILTERS='genomix_users.authentication.genomix_search_filters'LDAP_AUTH_SEARCH_FILTER='CN=dgd_nexus_users,ou=DGD Groups,ou=SecurityGroups,ou=Research,ou=Managed By Others,dc=chop,dc=edu'

将用户配置文件与settings.py中的ldap字段同步:

注意

如果在保存时创建配置文件=false,LDAP配置文件将不同步!

LDAP_AUTH_SYNC_USER_RELATIONS="genomix_users.authentication.sync_genomix_profile"# User model fields mapped to the LDAP attributes that represent them.LDAP_AUTH_PROFILE_FIELDS={"title":"title",}

功能

运行测试

代码真的有用吗?

source <YOURVIRTUALENV>/bin/activate
(myenv) $ pip install tox
(myenv) $ tox

学分

用于呈现此包的工具:

历史记录

0.1.0(2017-12-03)

  • pypi上的第一个版本。
  • 初始模型和rest api。

0.2.0(2017-12-11)

0.2.0 Changelog

  • 添加了配置文件。
  • 添加了从LDAP同步配置文件的功能。

0.3.0(2017-01-05)

0.3.0 Changelog

  • 添加了rest api过滤器。

0.3.1(2017-01-12)

0.3.1 Changelog

  • 修复了SimpleRouter的路由名称

0.4.0(2017-02-09)

0.4.0 Changelog

  • 最新更新要求

0.5.0(2017-04-07)

0.5.0 Changelog

  • 增加了对django 2.0和python 3.6的支持
  • 放弃了对django<;1.11和python 2.7、3.3、3.4的支持

0.5.1(2017-04-10)

0.5.1 Changelog

  • 修正了管理员注册的问题。从现在起-用户可以在其应用程序中导入并使用此功能

0.5.2(2017-04-18)

0.5.2 Changelog

  • 更新了第三方libs

0.5.3(2018-05-16)

0.5.3 Changelog

  • 已更新setup.py以读取install_requires from requirements.txt

0.5.4(2018-08-13)

0.5.4 Changelog

  • 更新的第三方要求。某些要求已更改,因此会导致故障

0.5.5(2018-10-29)

0.5.5 Changelog

  • 更新的第三方要求。

0.5.6(2019-02-08)

0.5.6 Changelog

  • 更新的第三方要求。

0.5.7(2019-04-10)

0.5.7 Changelog

  • 更新的第三方要求。

0.5.8(2019-05-31)

0.5.8 Changelog

  • 更新到最新的CookieCutter模板

0.5.9(2019-07-26)

0.5.9 Changelog

  • 更新的第三方要求。

0.5.10(2019-08-09)

0.5.10 Changelog

  • 更新的第三方要求。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
返回数组无效的java方法   异步Java CompletableFuture获取其请求   java是否可以像RDBMS那样使用视图?   java如何在屏幕上只运行一个片段?   java无法从Vertex jdbc查询中获取结果   java从jtable获取对象的正确方法   java Spring 3数据设备替代方案   Java BigDecimal:四舍五入到客户首选的数字和增量   JAVA主窗口没有出现,我必须左键单击主窗口。java并单击run查看它   Eclipse RCP中的java进程自定义设备事件   JavaEclipse一次又一次地构建代码(没有任何更改)?   java如何实现对象合并