当前位置:网站首页>Unified identity management platform IAM single sign-on process and third-party interface design scheme
Unified identity management platform IAM single sign-on process and third-party interface design scheme
2022-08-09 00:32:00 【Invincible Lulu handsome】
#统一身份管理平台IAM
Many companies have multiple office systems,账号、密码、角色、Permissions, etc. need to be set separately and cannot be managed uniformly.
Unified identity authentication management systemIAM,I think there are the following three advantages:
- Establish unified user management、Identity rationing and identity authentication systems,Realize dynamic synchronization of user identities and permissions.
- Implement all office systems(应用)的单点登录(B/S架构)or password authentication login(C/S架构).
- Strengthen information security early warning and auditing,提高系统可用性、Security and user portability.
即:One account can access multiple office systems within the enterprise,Covers multi-scenario control,支持部门,角色,Personnel dimension authorization.
#统一身份管理平台IAM单点登录流程图(B/S架构)
使用范围:需要实现单点登录,Use the login page of the unified identity management platform,and can sendhttpsThe requested third-party system,A brief summary of the following four steps:
- authorize接口,请求用户授权,Jump to the third-party system after completion.
- authorization_code接口,根据code获取授权Token.
- getUserInfo接口,根据Token获取用户信息.
- logout接口,注销登录.

This article will introduce the unified identity authentication platformIAMCommonly used single sign-on third-party interface design.
#1、请求用户授权,Jump to the third-party system after completion,网页设计
Web interface description:
| 请求类型 | GET/WEB网页访问 | |||||||||||||||
| 请求示例 | https://iam.xxxxx.com:8080/idp/oauth2/authorize?redirect_uri=https://www.baidu.com&state=xxxx&client_id=xxxxx&response_type=code | |||||||||||||||
| 参数说明 |
| |||||||||||||||
| 处理逻辑 | 1、判断参数; 2、验证client_id是否有效; 3、校验redirect_uri; 4、The Authentication and Authorization page is displayed; 5、After verifying the identity, the page jumps toredirect_uriAnd the parameter authorization code is attached(写入Cookie中). | |||||||||||||||
| 返回值 | Take the callback address in the above as Baidu as an example,After the authorization is completed, it will jump tohttps://www.baidu.com/?code=83953d36e2ae7c8903c6b589c8998670&state=xxxxx,携带参数code和state. |
实际操作:
WEBWeb page login authorization interface(GET请求)

Log in successfully and jump to the interface,携带参数code和state

#2、根据code获取TokenAuthorize third-party interface design
通过上文code即可以获取access_token和refresh_token,当access_token过期时,可以通过refresh_token重新获取新的access_token,保持登陆状态.
接口说明:
| 请求类型 | POST | |||||||||||||||
| 请求示例 | https://iam.xxxxx.com:8080/idp/oauth2/getToken?client_id=xxxxxx&grant_type=authorization_code&code=xxxxxx&client_secret=xxxxxx | |||||||||||||||
| 参数说明 |
| |||||||||||||||
| 处理逻辑 | 1、Verify parameter validity; 2、Verify the validity and scope of the authorization code; 3、根据以上判断、Verification and authentication results are returnedJSON数据. | |||||||||||||||
| 返回值 | 类型JSON,正确返回值: { "access_token": "5e717f5eda086269706a407e3764092a", "refresh_token": "fb6e93b627a1a93679251f605097503c", "uid": "20210311135809626-B457-4E410EFEB", "expires_in": 1500 } |
获取Token-POSTRequest interface sample code:
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.params.BasicHttpParams;
import org.apache.http.params.HttpConnectionParams;
import org.apache.http.util.EntityUtils;
public class getToken {
public static String getToken(String url){
BasicHttpParams http = new BasicHttpParams();
//设置请求超时1秒钟
HttpConnectionParams.setConnectionTimeout(http,1000);
//设置等待数据超时时间1秒钟
HttpConnectionParams.setSoTimeout(http,1000);
HttpClient client = new DefaultHttpClient(http);
String jsonresult = "";
try {
//Http Post请求
HttpPost post = new HttpPost(url);
HttpResponse response = client.execute(post);
//获取返回参数
HttpEntity entity =response.getEntity();
jsonresult = EntityUtils.toString(entity,"utf-8");
}catch (Exception ex){
ex.printStackTrace();
}finally {
client.getConnectionManager().shutdown();
}
return jsonresult;
}
public static void main(String[] args) {
String url = "https://iam.xxxxx.com:8080/idp/oauth2/getToken?client_id=SE&grant_type=authorization_code&code=dc605a7a6389b0898f653b4895359071&client_secret=6f369937851b4669ad66b41257b9a902";
//输出返回JSON字符串
System.out.println(getToken(url));
}
}#3、根据TokenThird-party interface design for obtaining user information
通过上文获取的access_tokento access the user interface,获取用户信息,Implement this user in a third-party system(应用)password-free login on .
接口说明:
| 请求类型 | GET | |||||||||
| 请求示例 | https://iam.xxxxx.com:8080/idp/oauth2/getUserInfo?access_token=xxxxx&client_id=xxxxx | |||||||||
| 参数说明 |
| |||||||||
| 处理逻辑 | 1、Verify parameter validity; 2、List of property permissions configured according to the app,Query user information and return; 3、根据以上判断、Verification and authentication results are returnedJSON数据. | |||||||||
| 返回值 | 类型JSON字符串,正确返回值: { "orgNamePath": "/人事处", "spRoleList": [], "uid": "20210311135809626-B457-4E410EFEB", "mail": "[email protected]", "orgCodePath": "W000001", "displayName": "李明", "loginName": "E012345678", "mobile": "13999999999", "orgNumber": "P00000000", "employeeNumber": null } |
获取用户信息-GETRequest interface sample code:
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.params.BasicHttpParams;
import org.apache.http.params.HttpConnectionParams;
import org.apache.http.util.EntityUtils;
public class getUserInfo {
public static String getToken(String url){
BasicHttpParams http = new BasicHttpParams();
//设置请求超时1秒钟
HttpConnectionParams.setConnectionTimeout(http,1000);
//设置等待数据超时时间1秒钟
HttpConnectionParams.setSoTimeout(http,1000);
HttpClient client = new DefaultHttpClient(http);
String jsonresult = "";
try {
//Http Get请求
HttpGet get = new HttpGet(url);
HttpResponse response = client.execute(get);
//获取返回参数
HttpEntity entity =response.getEntity();
jsonresult = EntityUtils.toString(entity,"utf-8");
}catch (Exception ex){
ex.printStackTrace();
}finally {
client.getConnectionManager().shutdown();
}
return jsonresult;
}
public static void main(String[] args) {
String url = "https://iam.xxxxx.com:8080/idp/oauth2/getUserInfo?access_token=xxxxx&client_id=xxxxx";
//输出返回JSON字符串
System.out.println(getToken(url));
}
}#4、Logout注销登录,Jump when done,网页设计
Third-party application system requestsIAMThe certification authority is globally withdrawnURL,The authentication authority destroys the user's global session,and call the app to destroy the sessionURL,This address needs to call the recovery authorization interface to clear the currentoauthThe ability to ticket and destroy application-local sessions.
流程图如下:

Web interface description:
| 请求类型 | GET/WEB网页访问 | ||||||||||||
| 请求示例 | https://iam.xxxxx.com:8080/idp/profile/OAUTH2/Redirect/GLO?redirctToUrl=https://www.baidu.com&redirectToLogin=true&entityId=xxxxx | ||||||||||||
| 参数说明 |
| ||||||||||||
| 处理逻辑 | 1、判断参数; 2、根据以上判断、Verification and authentication results are returnedJSON数据. | ||||||||||||
| 返回值 | Take the callback address in the above as Baidu as an example,Jump to after logouthttps://www.baidu.com,If jump tofalse,will stopIAM注销页面https://iam.xxxxx.com:8080/idp/http/logout.do |
边栏推荐
猜你喜欢
随机推荐
After the sessionStorage value is changed, the value obtained by the page using window.sessionStorage.getItem() will not be updated
图像分割、图像超分辨率简介
线程与线程池
怎么重置mysql的自增列AUTO_INCREMENT初时值
wordpress入门基本操作,网站安全防护及常用插件(建站必看教程)
bitset和bool哪个更快
pycharm开启鼠标滚动调节字体大小
求所有子串的最大值之和
Pytorch预训练模型和修改——记录
#468. 函数求和
VsCode配置自己喜欢的字体,背景,妈妈再也不担心我写代码枯燥了
对付流氓软件
Mysql Workbench导出sql文件出错:Error executing task: ‘ascii‘ codec can‘t decode byte 0xd0 in position 26:
在Windows环境下使用MySQL:自动定时备份
备份与恢复
动态style定义背景渐变
mysql 批量修改表及字段字符集
自考成绩总结
Error executing sql file from Mysql Workbench: Error executing task: 'ascii' codec can't decode byte 0xd0 in position 26:
阿里云服务器买完不知道如何使用(新手入门教程)









