Files
MaxKey/docs/authn/social.md

80 lines
3.2 KiB
Markdown
Raw Normal View History

2020-03-12 01:08:12 +08:00
<h2>第三方账号登录</h2>
为了方便用户的登录,可以通过第三方的账号(例如新浪微博、微信、钉钉等)登录MaxKey简单配置即可实现用户登录。
本文以新浪微博为例
<img src="{{ "/images/authn/authn_s_1.png" | prepend: site.baseurl }}?{{ site.time | date: "%Y%m%d%H%M" }}" alt=""/>
<h3>登录流程</h3>
<img src="{{ "/images/authn/authn_s.png" | prepend: site.baseurl }}?{{ site.time | date: "%Y%m%d%H%M" }}" alt=""/>
<h3>第三方认证配置</h3>
在新浪微博开放平台https://open.weibo.com/申请接入,新浪配置如下
<img src="{{ "/images/authn/authn_s_2.png" | prepend: site.baseurl }}?{{ site.time | date: "%Y%m%d%H%M" }}" alt=""/>
<img src="{{ "/images/authn/authn_s_3.png" | prepend: site.baseurl }}?{{ site.time | date: "%Y%m%d%H%M" }}" alt=""/>
<h3>认证配置</h3>
文件
2020-04-09 23:56:40 +08:00
maxkey/config/applicationConfig.properties
2020-03-12 01:08:12 +08:00
<pre><code class="ini hljs">
#enable social sign on
config.login.socialsignon=true
#sina weibo
config.socialsignon.sinaweibo.provider=sinaweibo
#登录提示
config.socialsignon.sinaweibo.provider.name=新浪微博
#图片
config.socialsignon.sinaweibo.icon=images/social/sinaweibo.png
#新浪client.id
config.socialsignon.sinaweibo.client.id=3379757634
#新浪client.secret
config.socialsignon.sinaweibo.client.secret=1adfdf9800299037bcab9d1c238664ba
#
config.socialsignon.sinaweibo.account.id=id
#排序
config.socialsignon.sinaweibo.sortorder=1
</code></pre>
配置maxkey/spring/maxkey-support-social.xml
<pre><code class="xml hljs">
2020-03-12 01:19:48 +08:00
&lt;bean id="socialSignOnWeibo" class="org.maxkey.authn.support.socialsignon.service.SocialSignOnProvider"&gt;
&lt;property name="provider" value="${config.socialsignon.sinaweibo.provider}"/&gt;
&lt;property name="providerName" value="${config.socialsignon.sinaweibo.provider.name}"/&gt;
&lt;property name="icon" value="${config.socialsignon.sinaweibo.icon}"/&gt;
&lt;property name="clientId" value="${config.socialsignon.sinaweibo.client.id}"/&gt;
&lt;property name="clientSecret" value="${config.socialsignon.sinaweibo.client.secret}"/&gt;
&lt;property name="sortOrder" value="${config.socialsignon.sinaweibo.sortorder}"/&gt;
&lt;/bean&gt;
&lt;bean id="socialSignOnProviderService" class="org.maxkey.authn.support.socialsignon.service.SocialSignOnProviderService"&gt;
&lt;property name="socialSignOnProviders" &gt;
&lt;list&gt;
&lt;ref bean="socialSignOnWeibo" /&gt;
&lt;/list&gt;
&lt;/property&gt;
&lt;/bean&gt;
2020-03-12 01:08:12 +08:00
</code></pre>
<h3>账号绑定</h3>
登录MaxKey并绑定新浪微博账号
<img src="{{ "/images/authn/authn_s_4.png" | prepend: site.baseurl }}?{{ site.time | date: "%Y%m%d%H%M" }}" alt=""/>
<h3>登录测试</h3>
退出后进入登录界面点击新浪微博图标跳转到新浪微博输入用户名和密码后直接登录MaxKey,即MaxKey信任了微博账号
<h3>第三方支持</h3>
2020-04-01 15:55:14 +08:00
MaxKey使用JustAuth作为第三方OAuth2登录认证库认证所支持的第三方请见JustAuth官方说明
2020-03-12 01:19:48 +08:00
2020-03-12 01:23:06 +08:00
<a href="https://docs.justauth.whnb.wang/#/" target="_blank" alt="JustAuth">
2020-04-01 15:56:51 +08:00
<img style="width:250px;" src="{{ "/images/authn/justauth.png" | prepend: site.baseurl }}?{{ site.time | date: "%Y%m%d%H%M" }}" alt=""/>
2020-03-12 01:23:06 +08:00
</a>