0%

Django SSO

Django实现SSO

1
pipenv install  django-simple-sso
1
2
3
INSTALLED_APPS = INSTALLED_APPS + (
'simple_sso.sso_server'
)
1
2
3
4
5

pipenv shell

>>> from simple_sso.sso_server.models import Token, Consumer
>>> Consumer.objects.create(public_key='application_public_key_kljdfwie8&5623o8*@#*&$#', private_key='application_private_key_lkjweinviiwn3n2388%$#', name='test_sso')

Test the URL http://127.0.0.1:8000/server/

image

Client1

1
2
3
4
5
# settings.py

SSO_PUBLIC_KEY = 'application_public_key_kljdfwie8&5623o8*@#*&$#'
SSO_PRIVATE_KEY = 'application_private_key_lkjweinviiwn3n2388%$#'
SSO_SERVER = '127.0.0.1:8001'
1
2
3
>>> from simple_sso.sso_client.client import Client
>>> from django.conf import settings
>>> test_client = Client(settings.SSO_SERVER, settings.SSO_PUBLIC_KEY, settings.SSO_PRIVATE_KEY)
1
path('client/', include(test_client.get_urls()))