跳转到主要内容

django oidc provider

项目描述

django-oidc-op

CI build pypi License Python version

这是一个基于 jwtconnect.io 的 Django 实现的 OIDC 提供商/OAuth2 AS。该项目基于 IdentityPython oidc-op。有关其功能和特性的更多信息,请参阅官方 oidc-op 文档

配置标准 OIDC 提供商,您需要编辑 oidcop 配置文件。查看 django-oidc-op/oidc_provider/tests/example/example/settings.pydjango-oidc-op/oidc_provider/tests/example/example/oidc_provider_settings.py 以获取更多信息。

运行示例演示

git clone https://github.com/peppelinux/django-oidc-op.git
cd django-oidc-op

pip install -r requirements.txt
cd example

./manage.py createsuperuser

bash run.sh

示例依赖方

您可以使用 JWTConnect-Python-OidcRP 如下所示

cd JWTConnect-Python-OidcRP/example
RP_LOGFILE_NAME="./flrp.django.log" python3 -m flask_rp.wsgi ../django-oidc-op/example/data/oidc_rp/conf.django.yaml

您还可以在 oidc-rp 上使用脚本化 RP 处理程序

python3 snippets/rp_handler.py -c oidc_provider/tests/oidc_rp/conf.json -u test -p testami18 -iss django_provider

配置

该项目完全依赖于 oidcop 提供的行为和功能,为了在 Django 中实现彻底的集成,它采用了以下自定义。

oidc_provider_settings.py

在示例项目中,它处理了所有 oidcop 配置。我认为这更简洁,但请随意根据您喜欢的架构进行适配。

设置

  • OIDCOP_CONFIG 是一个包含 oidcop 配置的 Python 字典。
  • OIDC_URL_PREFIX,例如:如果存在,将用作所有 oidcop 端点的 URL 路径,除了 .well-known/openid-configuration。在示例项目中,我将此参数放在 oidc_provider_settings 中,默认为 ''

用户信息端点

即将发布的声明配置在 op.server_info.user_info(在 oidc_provider_settings.py 文件中)。发布属性和用户身份验证机制依赖于 oidc_op/users.py 中实现的类。

配置示例

      "userinfo": {
        "class": "oidc_provider.users.UserInfo",
        "kwargs": {
            # map claims to django user attributes here:
            "claims_map": {
                "phone_number": "telephone",
                "family_name": "last_name",
                "given_name": "first_name",
                "email": "email",
                "verified_email": "email",
                "gender": "gender",
                "birthdate": "get_oidc_birthdate",
                "updated_at": "get_oidc_lastlogin"
            }
        }
      }

开发者

运行测试

运行测试

./manage.py test oidc_provider

覆盖率

coverage erase
coverage run manage.py test oidc_provider
coverage report -m

作者

  • Giuseppe De Marco

画廊

依赖方

Alt text Alt text

会话管理和令牌预览

Alt text Alt text Alt text

项目详情


下载文件

下载适合您平台的文件。如果您不确定选择哪个,请了解有关 安装包 的更多信息。

源分布

oidc_provider-2.3.4.tar.gz (2.5 MB 查看哈希值

上传时间

由以下支持

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误日志 StatusPage StatusPage 状态页