当前位置:网站首页>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 |
边栏推荐
- pycharm更改默认项目地址的方法
- 解决8080端口被占用问题
- 云服务器可以用来做什么?有什么用途?
- Why software development methodology make you feel bad?
- Error executing sql file from Mysql Workbench: Error executing task: 'ascii' codec can't decode byte 0xd0 in position 26:
- 纹理映射-TextureMapping
- 手把手教你云服务器如何搭建typecho博客网站(包括配置免费SSL证书)
- vscode 中新建文件自动显示作者,日期等配置
- GaN图腾柱无桥 Boost PFC(单相)四(仿真理解)
- Flutter -自定义日历组件
猜你喜欢
aspx结尾文件网站的发布过程
整流十四---直接功率控制策略
数学建模美赛题型分类
在Ubuntu/Linux环境下使用MySQL:修改数据库sql_mode,可解决“this is incompatible with sql_mode=only_full_group_by”问题
WeChat applet console error - summary 】 【
整流七 - 三相PWM整流器—公式推导篇
图像分割、图像超分辨率简介
笔记&代码 | 统计学——基于R(第四版) 第四章随机变量的概率分布
如何使用Rancher部署发布自己的web应用
Several ways to implement inheritance in js
随机推荐
小程序textarea完美填坑
GaN图腾柱无桥 Boost PFC(单相)五-细节处理
求区间(L, R)小于k的数有多少个
牛客小白月赛 37 补题
牛客多校8 补题
线性复杂度优化 / 离散化
安装wcf框架
IIS发布程序,出现:请求的内容似乎是脚本,因而将无法由静态文件处理程序来处理解决方案
【全排列】
【StoneDB Class】入门第三课:StoneDB 的安装编译
Error executing sql file from Mysql Workbench: Error executing task: 'ascii' codec can't decode byte 0xd0 in position 26:
对于js中apply和call的区别和用法
[Deep Learning] TensorFlow Learning Road 2: Introduction to ANN and TensorFlow Implementation
MySQL5.7设置MySQL/MariaDB 数据库默认编码为utf8mb4
笔记| 矩阵分析中需要复习的线性代数知识
为什么软件开发方法论让你觉得糟糕?
Dart高级(一)——泛型与Json To Bean
MVC与MVP的区别
棋盘从左上角走到右下角方案数
插值拟合——数据处理或预测