Skip to main content

Openauth

Openauth 是 统一认证平台的 django 插件。

通过这个插件,django 可以与 统一认证平台 集成起来,直接具备如 企业微信 登录能力。

原理上,就是直接改写 django admin 的 login 页,使其接受 jwt 参数,判断 jwt 合法性,从中解析用户账号。 如果账号存在,则直接登录,如果不存在,则创建后再置为登录态。

其中统一认证平台可以自己搭建。

Quick start

  1. 安装

    pip install django-openauth
  2. 在 settings 加入 uniauth

    INSTALLED_APPS = [
        ...
        'openauth',
    ]
  3. 在 urls.py 加入 openauth

    path('openauth/', include('openauth.urls')),
  4. 同步数据库

    python manage.py migrate
  5. 访问 http://localhost:8000/admin 看效果

配置项

  • settings 支持以下配置项:

    • OPENAUTH_JWT_SECRET:如果该配置项有值,或值不为空字符串,则 jwt 的认证 secret 从该项获取。 这时不需要 redis。若该配置项为空,则 openauth 会从 Redis 中的 jwt_secret 中获取 secret

  • 如果 jwt secret 从 redis 中获取,请在 settings 的 cache 中这么配置:

    CACHES = {
       'default': {
           ...
       },
       'openauth': {
           "BACKEND": "django_redis.cache.RedisCache",
           "LOCATION": f"redis://{config.openauth_redis_host}:{config.openauth_redis_port}/{config.openauth_redis_db}",
           'KEY_PREFIX': '',
           "OPTIONS": {
               "CLIENT_CLASS": "django_redis.client.DefaultClient",
               "PASSWORD": f"{config.openauth_redis_password}"
           }
       }
    }

Metadata

Release files for django-openauth 0.3.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-openauth 0.3.6
File Size Uploaded Provenance Actions
django-openauth-0.3.6.tar.gz 10.4 kB Without provenance Details for django-openauth-0.3.6.tar.gz

Release files / django-openauth-0.3.6.tar.gz

Download URL django-openauth-0.3.6.tar.gz
Size 10.4 kB
Tags Source
SHA-256 checksum
How to use checksums
a00debb0b1953a0321d1b6818455817571f4352c676b4c2959b555983cfb4821
BLAKE2b-256 checksum
How to use checksums
ebbd092c7424ab1dc2e50cdd8aabc7de2cf656487d87ee41545b4187686980c3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.40.2 CPython/3.6.9

Security for django-openauth 0.3.6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page