Skip to main content

统一认证平台的 django 插件

Project description

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}"
           }
       }
    }

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-openauth-0.3.6.tar.gz (10.4 kB view details)

Uploaded Source

File details

Details for the file django-openauth-0.3.6.tar.gz.

File metadata

  • Download URL: django-openauth-0.3.6.tar.gz
  • Upload date:
  • Size: 10.4 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for django-openauth-0.3.6.tar.gz
Algorithm Hash digest
SHA256 a00debb0b1953a0321d1b6818455817571f4352c676b4c2959b555983cfb4821
MD5 e688a8d5ef152b15beed092bf785d242
BLAKE2b-256 ebbd092c7424ab1dc2e50cdd8aabc7de2cf656487d87ee41545b4187686980c3

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page