django openid connect(oidc)身份验证后端

django-oidc-tf的Python项目详细描述


此模块使在django项目中集成openid connect作为身份验证源变得容易。

在幕后,它使用罗兰·赫德伯格(Roland Hedberg)伟大的结节病图书馆。

由Jhuapl boss修改以支持python3

由thomas fróssman修改,包括修复和附加修改。

快速启动

安装djangooidc:

# Latest (pre) release
pip install django-oidc-tf


# Latest code - unstable!
pip install git+https://github.com/thomasf/django-oidc.git

然后要在django项目中使用它,请将其添加到您的url.py:

url(r'openid/', include('djangooidc.urls')),

然后将以下项目添加到您的设置中。py:

  • 在默认值之后将“djangooidc.backends.openidconnectbackend”添加到身份验证后端'django.contrib.auth.backends.modelbackend'

  • 设置登录url='openid'

  • 添加特定的oidc参数(更改您的绝对url):

    # Information used when registering the client, this may be the same for all OPs
    # Ignored if auto registration is not used.
    OIDC_DYNAMIC_CLIENT_REGISTRATION_DATA = {
        "application_type": "web",
        "contacts": ["ops@example.com"],
        "redirect_uris": ["http://localhost:8000/openid/callback/login/", ],
        "post_logout_redirect_uris": ["http://localhost:8000/openid/callback/logout/", ]
    }
    
    # Default is using the 'code' workflow, which requires direct connectivity from your website to the OP.
    OIDC_DEFAULT_BEHAVIOUR = {
        "response_type": "code",
        "scope": ["openid", "profile", "email", "address", "phone"],
    }
    

上面的配置足以使用支持发现和自客户端注册的oidc提供程序(op)。 此外,您可能需要使用一个特定的openid连接提供程序,它不是自动发现的。完成了 通过将项添加到oidc\u providers字典。有关参数名称,请参阅完整文档。

例如,azure广告操作将是:

OIDC_PROVIDERS = {
    "Azure Active Directory": {
        "srv_discovery_url": "https://sts.windows.net/aaaaaaaa-aaaa-1111-aaaa-xxxxxxxxxxxxx/",
        "behaviour": OIDC_DEFAULT_BEHAVIOUR,
        "client_registration": {
            "client_id": "your_client_id",
            "client_secret": "your_client_secret",
            "redirect_uris": ["http://localhost:8000/openid/callback/login/"],
            "post_logout_redirect_uris": ["http://localhost:8000/openid/callback/logout/"],
        }
    }
}

现在可以通过转到(在开发服务器上)或任何 需要验证的视图。

功能

  • 准备使用Django身份验证后端
  • 数据库中没有存储任何模型-只是在settings.py中进行一些配置,以使其保持简单
  • 与Django的内部帐户和权限系统完全集成
  • 支持所有oidc工作流:授权代码流、隐式流、混合流。不知道就别担心 这些是什么-这个包有很好的默认值。
  • 包括在提供商级别注销

历史记录

0.1.0(2015-05-08)

  • 首次发布

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

推荐PyPI第三方库


热门话题
java谷歌扳手单例重新连接故障   使用AES公钥加密的java Proxyreencryption   java EJB拦截器与CDI拦截器   启动appium browser:org时发生java错误。openqa。硒。WebDriverException:运行Appium命令时出错:路径参数。解析必须是字符串   java在Eclipse项目设置中执行环境的重要性   java如何创建容量受限队列实现?   mysql如何将桌面java应用程序连接到在线数据库(适用于傻瓜)?   如何使用java在给定的时间限制内在会话超时之前在数据库中插入数据?   Java运算符的if语句逻辑&&and||   java Spring启动测试失败,原因是缺少ServletWebServerFactory bean,无法启动ServletWebServerApplicationContext   java有没有办法获取实例中属性/字段的顺序?   如何在没有withColumn的情况下将Spark数据集的所有列强制转换为Java中的字符串?   java allocateIds DatastoreService真实世界使用情况   Java的strictfp修饰符是否通过函数调用应用浮点?   html简单Java小程序未在浏览器中显示   Java 2D平台:一些逻辑/物理怪癖