我在Apache Ubuntu 16.04服务器上有两个Web应用程序:
我想安装单点登录服务(SSO)。例如,用户登录WordPress,然后当他访问Django网站时,他已经连接。实际上我在WordPress和Django之间没有找到任何关于SSO的信息。你知道怎么做吗?
答案 0 :(得分:1)
在wordpress网站中使用以下插件工具JWT令牌进行身份验证 https://wordpress.org/plugins/jwt-authentication-for-wp-rest-api/
成功登录wordpress网站后重定向到Django网站,在Django中注销时。在wordpress 反之亦然
中销毁会话答案 1 :(得分:1)
我使用了这个https://wordpress.org/plugins/jwt-authentication-for-wp-rest-api/ 用于WP登录
我为auth_user(Django)和wp_users(Wordpress)创建了两个插入函数 安装库
pip install passlib
serializer.py(即时通讯使用django rest_framework jwt)
从passlib.hash导入md5_crypt
从django.contrib.auth.hashers导入make_password
pwd_hash = make_password(password)
usrobj = User(username = username, email = email, is_active=True, password = pwd_hash)
usrobj.save()
wph = md5_crypt.hash(password)
wpusrobj = WpUsers(user_login = str(username), user_pass = str(wph), user_nicename='', user_email = str(email), user_url='', user_activation_key='', display_name='', user_status=0)
wpusrobj.save()
python manage.py inspectdb > models.py
它应该看起来像这样:(我只添加一些null和空白)
class WpUsers(models.Model):
id = models.BigAutoField(db_column='ID', primary_key=True) # Field name made lowercase.
user_login = models.CharField(max_length=60)
user_pass = models.CharField(max_length=255)
user_nicename = models.CharField(max_length=50, blank=True, null=True)
user_email = models.CharField(max_length=100)
user_url = models.CharField(max_length=100, blank=True, null=True)
user_registered = models.DateTimeField(("Created Date"), default=timezone.now, blank=True, null=True)
user_activation_key = models.CharField(max_length=255, blank=True, null=True)
user_status = models.IntegerField(null=True, blank=True)
display_name = models.CharField(max_length=250, blank=True, null=True)
class Meta:
managed = False
db_table = 'wp_users'