微软adfs和azuread的django认证后端

django-auth-adfs的Python项目详细描述


django的adfs身份验证

文档状态https://img.shields.io/pypi/v/django-auth-adfs.svg 下载" rel="nofollow"> https://img.shields.io/pypi/pyversions/django-auth-adfs.svghttps://img.shields.io/pypi/djversions/django-auth-adfs.svghttps://travis-ci.org/jobec/django-auth-adfs.svg?branch=masterhttps://codecov.io/github/jobec/django-auth-adfs/coverage.svg?branch=master

Microsoft ADFS和Azure AD的Django身份验证后端

  • 免费软件:BSD许可证
  • 主页:https://github.com/jobec/django-auth-adfs" rel="nofollow">https://github.com/jobec/django auth-adfs
  • 文档:http://django-auth-adfs.readthedocs.io/" rel="nofollow">http://django-auth-adfs.readthedocs.io/

功能

  • 将django与Windows 2012 R2、2016或云中的azure ad上的活动目录集成。
  • 在Intranet环境中为Django项目提供无缝单点登录(SSO)。
  • 根据从ADF接收到的信息,自动创建用户并将其添加到Django组。
  • django rest framework(drf)集成:使用adfs访问令牌根据api进行身份验证。

安装

python包:

pip install django-auth-adfs

在项目的 设置中。py 添加这些设置。

AUTHENTICATION_BACKENDS=(...'django_auth_adfs.backend.AdfsAuthCodeBackend',...)INSTALLED_APPS=(...# Needed for the ADFS redirect URI to function'django_auth_adfs',...# checkout the documentation for more settingsAUTH_ADFS={"SERVER":"adfs.yourcompany.com","CLIENT_ID":"your-configured-client-id","RELYING_PARTY_ID":"your-adfs-RPT-name",# Make sure to read the documentation about the AUDIENCE setting# when you configured the identifier as a URL!"AUDIENCE":"microsoft:identityserver:your-RelyingPartyTrust-identifier","CA_BUNDLE":"/path/to/ca-bundle.pem","CLAIM_MAPPING":{"first_name":"given_name","last_name":"family_name","email":"email"},}# Configure django to redirect users to the right URL for loginLOGIN_URL="django_auth_adfs:login"LOGIN_REDIRECT_URL="/"######################### OPTIONAL SETTINGS########################MIDDLEWARE=(...# With this you can force a user to login without using# the LoginRequiredMixin on every view class## You can specify URLs for which login is not enforced by# specifying them in the LOGIN_EXEMPT_URLS setting.'django_auth_adfs.middleware.LoginRequiredMiddleware',)

在项目的 url.py 中添加以下路径:

urlpatterns=[...path('oauth2/',include('django_auth_adfs.urls')),]

这将把这些路径添加到django:

  • /oauth2/login 将用户重定向到其中,以使用adfs启动登录。
  • /oauth2/login_no_sso 将用户重定向到其中,以使用adfs启动登录,但强制显示登录屏幕。
  • /oauth2/callback 其中adfs在登录后重定向回。因此,请确保将adfs上的重定向uri设置为此。
  • /oauth2/logout 从django和adfs注销用户。

您可以在django模板中这样使用它们:

<ahref="{% url 'django_auth_adfs:logout' %}">Logout</a><ahref="{% url 'django_auth_adfs:login' %}">Login</a><ahref="{% url 'django_auth_adfs:login-no-sso' %}">Login (no SSO)</a>

贡献

对法典的贡献更多那欢迎。 有关更多详细信息,请查看 contribution.rst 文件。

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

推荐PyPI第三方库


热门话题
java SimpleFramework和工厂方法   Java适当地处理异常   java单例类不起作用   java小程序和Swing在eclipse中不显示组件   多个键上的java Redisson FastRemove不起作用   java验证请求正文不等于模式   在Java中从URL读取数据   eche RecyclerView项的java Set自定义字体   string Java如何从Date获取HH:mm:ss   当Java应用程序落后于负载均衡器时,在某些URL上强制使用SSL   使用esapi时发生java错误   java使用流根据第二个列表中的值更新一个列表中的对象   组织。openqa。硒。Java中的NoTouchElementException WebDriver?   从JSON字符串Java创建CSV文件