单点登录系统实现基于SpringBoot
今天的干货有点湿,里面夹杂着我的泪水。可能也只有代码才能让我暂时的平静。通过本章内容你将学到单点登录系统和传统登录系统的区别,单点登录系统设计思路,Spring4 Java配置方式整合HttpClient,整合Redis ,HttpClient简易教程。还在等什么?撸起袖子开始干吧!
效果图:8081端口是sso系统,其他两个8082和8083端口模拟两个系统。登录成功后检查Redis数据库中是否有值。
技术:SpringBoot,SpringMVC,Spring,SpringData,Redis,HttpClient
说明:本章的用户登录注册的代码部分已经在SpringBoot基础入门中介绍过了,这里不会重复贴代码。
源码: https://github.com/ITDragonBlog/daydayup/tree/master/SpringBoot-SSO
SpringBoot基础入门:http://www.cnblogs.com/itdragon/p/8047132.html
单点登录系统简介

在传统的系统,或者是只有一个服务器的系统中。Session在一个服务器中,各个模块都可以直接获取,只需登录一次就进入各个模块。若在服务器集群或者是分布式系统架构中,每个服务器之间的Session并不是共享的,这会出现每个模块都要登录的情况。这时候需要通过单点登录系统(Single Sign On)将用户信息存在Redis数据库中实现Session共享的效果。从而实现一次登录就可以访问所有相互信任的应用系统。
单点登录系统实现
Maven项目核心配置文件 pom.xml 需要在原来的基础上添加 httpclient和jedis jar包
<dependency> <!-- http client version is 4.5.3 -->
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</dependency>
<dependency> <!-- redis java client version is 2.9.0 -->
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
</dependency>
Spring4 Java配置方式
这里,我们需要整合httpclient用于各服务之间的通讯(也可以用okhttp)。同时还需要整合redis用于存储用户信息(Session共享)。
在Spring3.x之前,一般在应用的基本配置用xml,比如数据源、资源文件等。业务开发用注解,比如Component,Service,Controller等。其实在Spring3.x的时候就已经提供了Java配置方式。现在的Spring4.x和SpringBoot都开始推荐使用Java配置方式配置bean。它可以使bean的结构更加的清晰。
整合 HttpClient
HttpClient 是 Apache Jakarta Common 下的子项目,用来提供高效的、最新的、功能丰富的支持 HTTP 协议的客户端编程工具包,并且它支持 HTTP 协议最新的版本和建议。
HttpClient4.5系列教程 : http://blog.csdn.net/column/details/httpclient.html
首先在src/main/resources 目录下创建 httpclient.properties 配置文件
#设置整个连接池默认最大连接数
http.defaultMaxPerRoute=100
#设置整个连接池最大连接数
http.maxTotal=300
#设置请求超时
http.connectTimeout=1000
#设置从连接池中获取到连接的最长时间
http.connectionRequestTimeout=500
#设置数据传输的最长时间
http.socketTimeout=10000
然后在 src/main/java/com/itdragon/config 目录下创建 HttpclientSpringConfig.java 文件
这里用到了四个很重要的注解
@Configuration : 作用于类上,指明该类就相当于一个xml配置文件
@Bean : 作用于方法上,指明该方法相当于xml配置中的,注意方法名的命名规范
@PropertySource : 指定读取的配置文件,引入多个value={"xxx:xxx","xxx:xxx"},ignoreResourceNotFound=true 文件不存在时忽略
@Value : 获取配置文件的值,该注解还有很多语法知识,这里暂时不扩展开
package com.itdragon.config;
import java.util.concurrent.TimeUnit;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.client.IdleConnectionEvictor;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.context.annotation.Scope;
/**
* @Configuration 作用于类上,相当于一个xml配置文件
* @Bean 作用于方法上,相当于xml配置中的<bean>
* @PropertySource 指定读取的配置文件
* @Value 获取配置文件的值
*/
@Configuration
@PropertySource(value = "classpath:httpclient.properties")
public class HttpclientSpringConfig {
@Value("${http.maxTotal}")
private Integer httpMaxTotal;
@Value("${http.defaultMaxPerRoute}")
private Integer httpDefaultMaxPerRoute;
@Value("${http.connectTimeout}")
private Integer httpConnectTimeout;
@Value("${http.connectionRequestTimeout}")
private Integer httpConnectionRequestTimeout;
@Value("${http.socketTimeout}")
private Integer httpSocketTimeout;
@Autowired
private PoolingHttpClientConnectionManager manager;
@Bean
public PoolingHttpClientConnectionManager poolingHttpClientConnectionManager() {
PoolingHttpClientConnectionManager poolingHttpClientConnectionManager = new PoolingHttpClientConnectionManager();
// 最大连接数
poolingHttpClientConnectionManager.setMaxTotal(httpMaxTotal);
// 每个主机的最大并发数
poolingHttpClientConnectionManager.setDefaultMaxPerRoute(httpDefaultMaxPerRoute);
return poolingHttpClientConnectionManager;
}
@Bean // 定期清理无效连接
public IdleConnectionEvictor idleConnectionEvictor() {
return new IdleConnectionEvictor(manager, 1L, TimeUnit.HOURS);
}
@Bean // 定义HttpClient对象 注意该对象需要设置scope="prototype":多例对象
@Scope("prototype")
public CloseableHttpClient closeableHttpClient() {
return HttpClients.custom().setConnectionManager(this.manager).build();
}
@Bean // 请求配置
public RequestConfig requestConfig() {
return RequestConfig.custom().setConnectTimeout(httpConnectTimeout) // 创建连接的最长时间
.setConnectionRequestTimeout(httpConnectionRequestTimeout) // 从连接池中获取到连接的最长时间
.setSocketTimeout(httpSocketTimeout) // 数据传输的最长时间
.build();
}
}
整合 Redis
SpringBoot官方其实提供了spring-boot-starter-redis pom 帮助我们快速开发,但我们也可以自定义配置,这样可以更方便地掌控。
Redis 系列教程 : http://www.cnblogs.com/itdragon/category/1122427.html
首先在src/main/resources 目录下创建 redis.properties 配置文件
设置Redis主机的ip地址和端口号,和存入Redis数据库中的key以及存活时间。这里为了方便测试,存活时间设置的比较小。这里的配置是单例Redis。
redis.node.host=192.168.225.131
redis.node.port=6379
REDIS_USER_SESSION_KEY=REDIS_USER_SESSION
SSO_SESSION_EXPIRE=30
在src/main/java/com/itdragon/config 目录下创建 RedisSpringConfig.java 文件
package com.itdragon.config;
import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;
import redis.clients.jedis.JedisShardInfo;
import redis.clients.jedis.ShardedJedisPool;
@Configuration
@PropertySource(value = "classpath:redis.properties")
public class RedisSpringConfig {
@Value("${redis.maxTotal}")
private Integer redisMaxTotal;
@Value("${redis.node.host}")
private String redisNodeHost;
@Value("${redis.node.port}")
private Integer redisNodePort;
private JedisPoolConfig jedisPoolConfig() {
JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
jedisPoolConfig.setMaxTotal(redisMaxTotal);
return jedisPoolConfig;
}
@Bean
public JedisPool getJedisPool(){ // 省略第一个参数则是采用 Protocol.DEFAULT_DATABASE
JedisPool jedisPool = new JedisPool(jedisPoolConfig(), redisNodeHost, redisNodePort);
return jedisPool;
}
@Bean
public ShardedJedisPool shardedJedisPool() {
List<JedisShardInfo> jedisShardInfos = new ArrayList<JedisShardInfo>();
jedisShardInfos.add(new JedisShardInfo(redisNodeHost, redisNodePort));
return new ShardedJedisPool(jedisPoolConfig(), jedisShardInfos);
}
}
Service 层
在src/main/java/com/itdragon/service 目录下创建 UserService.java 文件,它负责三件事情
第一件事情:验证用户信息是否正确,并将登录成功的用户信息保存到Redis数据库中。
第二件事情:负责判断用户令牌是否过期,若没有则刷新令牌存活时间。
第三件事情:负责从Redis数据库中删除用户信息。
这里用到了一些工具类,不影响学习,可以从源码中直接获取。
package com.itdragon.service;
import java.util.UUID;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.transaction.Transactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import com.itdragon.pojo.ItdragonResult;
import com.itdragon.pojo.User;
import com.itdragon.repository.JedisClient;
import com.itdragon.repository.UserRepository;
import com.itdragon.utils.CookieUtils;
import com.itdragon.utils.ItdragonUtils;
import com.itdragon.utils.JsonUtils;
@Service
@Transactional
@PropertySource(value = "classpath:redis.properties")
public class UserService {
@Autowired
private UserRepository userRepository;
@Autowired
private JedisClient jedisClient;
@Value("${REDIS_USER_SESSION_KEY}")
private String REDIS_USER_SESSION_KEY;
@Value("${SSO_SESSION_EXPIRE}")
private Integer SSO_SESSION_EXPIRE;
public ItdragonResult userLogin(String account, String password,
HttpServletRequest request, HttpServletResponse response) {
// 判断账号密码是否正确
User user = userRepository.findByAccount(account);
if (!ItdragonUtils.decryptPassword(user, password)) {
return ItdragonResult.build(400, "账号名或密码错误");
}
// 生成token
String token = UUID.randomUUID().toString();
// 清空密码和盐避免泄漏
String userPassword = user.getPassword();
String userSalt = user.getSalt();
user.setPassword(null);
user.setSalt(null);
// 把用户信息写入 redis
jedisClient.set(REDIS_USER_SESSION_KEY + ":" + token, JsonUtils.objectToJson(user));
// user 已经是持久化对象,被保存在session缓存当中,若user又重新修改属性值,那么在提交事务时,此时 hibernate对象就会拿当前这个user对象和保存在session缓存中的user对象进行比较,如果两个对象相同,则不会发送update语句,否则会发出update语句。
user.setPassword(userPassword);
user.setSalt(userSalt);
// 设置 session 的过期时间
jedisClient.expire(REDIS_USER_SESSION_KEY + ":" + token, SSO_SESSION_EXPIRE);
// 添加写 cookie 的逻辑,cookie 的有效期是关闭浏览器就失效。
CookieUtils.setCookie(request, response, "USER_TOKEN", token);
// 返回token
return ItdragonResult.ok(token);
}
public void logout(String token) {
jedisClient.del(REDIS_USER_SESSION_KEY + ":" + token);
}
public ItdragonResult queryUserByToken(String token) {
// 根据token从redis中查询用户信息
String json = jedisClient.get(REDIS_USER_SESSION_KEY + ":" + token);
// 判断是否为空
if (StringUtils.isEmpty(json)) {
return ItdragonResult.build(400, "此session已经过期,请重新登录");
}
// 更新过期时间
jedisClient.expire(REDIS_USER_SESSION_KEY + ":" + token, SSO_SESSION_EXPIRE);
// 返回用户信息
return ItdragonResult.ok(JsonUtils.jsonToPojo(json, User.class));
}
}
Controller 层
负责跳转登录页面跳转
package com.itdragon.controller;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class PageController {
@RequestMapping("/login")
public String showLogin(String redirect, Model model) {
model.addAttribute("redirect", redirect);
return "login";
}
}
负责用户的登录,退出,获取令牌的操作
package com.itdragon.controller;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import com.itdragon.pojo.ItdragonResult;
import com.itdragon.service.UserService;
@Controller
@RequestMapping("/user")
public class UserController {
@Autowired
private UserService userService;
@RequestMapping(value="/login", method=RequestMethod.POST)
@ResponseBody
public ItdragonResult userLogin(String username, String password,
HttpServletRequest request, HttpServletResponse response) {
try {
ItdragonResult result = userService.userLogin(username, password, request, response);
return result;
} catch (Exception e) {
e.printStackTrace();
return ItdragonResult.build(500, "");
}
}
@RequestMapping(value="/logout/{token}")
public String logout(@PathVariable String token) {
userService.logout(token); // 思路是从Redis中删除key,实际情况请和业务逻辑结合
return "index";
}
@RequestMapping("/token/{token}")
@ResponseBody
public Object getUserByToken(@PathVariable String token) {
ItdragonResult result = null;
try {
result = userService.queryUserByToken(token);
} catch (Exception e) {
e.printStackTrace();
result = ItdragonResult.build(500, "");
}
return result;
}
}
视图层
一个简单的登录页面
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!doctype html>
<html lang="zh">
<head>
<meta name="viewport" content="initial-scale=1.0, width=device-width, user-scalable=no" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,Chrome=1" />
<meta http-equiv="X-UA-Compatible" content="IE=8" />
<title>欢迎登录</title>
<link type="image/x-icon" href="images/favicon.ico" rel="shortcut icon">
<link rel="stylesheet" href="static/css/main.css" />
</head>
<body>
<div class="wrapper">
<div class="container">
<h1>Welcome</h1>
<form method="post" onsubmit="return false;" class="form">
<input type="text" value="itdragon" name="username" placeholder="Account"/>
<input type="password" value="123456789" name="password" placeholder="Password"/>
<button type="button" id="login-button">Login</button>
</form>
</div>
<ul class="bg-bubbles">
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
</div>
<script type="text/javascript" src="static/js/jquery-1.10.1.min.js" ></script>
<script type="text/javascript">
var redirectUrl = "${redirect}"; // 浏览器中返回的URL
function doLogin() {
$.post("/user/login", $(".form").serialize(),function(data){
if (data.status == 200) {
if (redirectUrl == "") {
location.href = "http://localhost:8082";
} else {
location.href = redirectUrl;
}
} else {
alert("登录失败,原因是:" + data.msg);
}
});
}
$(function(){
$("#login-button").click(function(){
doLogin();
});
});
</script>
</body>
</html>
HttpClient 基础语法
这里封装了get,post请求的方法
package com.itdragon.utils;
import java.io.IOException;
import java.net.URI;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.apache.http.NameValuePair;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
public class HttpClientUtil {
public static String doGet(String url) {// 无参数get请求
return doGet(url, null);
}
public static String doGet(String url, Map<String, String> param) {// 带参数get请求
CloseableHttpClient httpClient = HttpClients.createDefault();// 创建一个默认可关闭的Httpclient 对象
String resultMsg = "";// 设置返回值
CloseableHttpResponse response = null;// 定义HttpResponse 对象
try {
URIBuilder builder = new URIBuilder(url);// 创建URI,可以设置host,设置参数等
if (param != null) {
for (String key : param.keySet()) {
builder.addParameter(key, param.get(key));
}
}
URI uri = builder.build();
HttpGet httpGet = new HttpGet(uri);// 创建http GET请求
response = httpClient.execute(httpGet); // 执行请求
if (response.getStatusLine().getStatusCode() == 200) { // 判断返回状态为200则给返回值赋值
resultMsg = EntityUtils.toString(response.getEntity(), "UTF-8");
}
} catch (Exception e) {
e.printStackTrace();
} finally { // 不要忘记关闭
try {
if (response != null) {
response.close();
}
httpClient.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return resultMsg;
}
public static String doPost(String url) { // 无参数post请求
return doPost(url, null);
}
public static String doPost(String url, Map<String, String> param) {// 带参数post请求
CloseableHttpClient httpClient = HttpClients.createDefault();// 创建一个默认可关闭的Httpclient 对象
CloseableHttpResponse response = null;
String resultMsg = "";
try {
HttpPost httpPost = new HttpPost(url); // 创建Http Post请求
if (param != null) { // 创建参数列表
List<NameValuePair> paramList = new ArrayList<NameValuePair>();
for (String key : param.keySet()) {
paramList.add(new BasicNameValuePair(key, param.get(key)));
}
UrlEncodedFormEntity entity = new UrlEncodedFormEntity(paramList);// 模拟表单
httpPost.setEntity(entity);
}
response = httpClient.execute(httpPost);// 执行http请求
if (response.getStatusLine().getStatusCode() == 200) {
resultMsg = EntityUtils.toString(response.getEntity(), "utf-8");
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (response != null) {
response.close();
}
httpClient.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return resultMsg;
}
public static String doPostJson(String url, String json) {
CloseableHttpClient httpClient = HttpClients.createDefault();
CloseableHttpResponse response = null;
String resultString = "";
try {
HttpPost httpPost = new HttpPost(url);
StringEntity entity = new StringEntity(json, ContentType.APPLICATION_JSON);
httpPost.setEntity(entity);
response = httpClient.execute(httpPost);
if (response.getStatusLine().getStatusCode() == 200) {
resultString = EntityUtils.toString(response.getEntity(), "utf-8");
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (response != null) {
response.close();
}
httpClient.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return resultString;
}
}
Spring 自定义拦截器
这里是另外一个项目 itdragon-service-test-sso 中的代码,
首先在src/main/resources/spring/springmvc.xml 中配置拦截器,设置那些请求需要拦截
<!-- 拦截器配置 -->
<mvc:interceptors>
<mvc:interceptor>
<mvc:mapping path="/github/**"/>
<bean class="com.itdragon.interceptors.UserLoginHandlerInterceptor"/>
</mvc:interceptor>
</mvc:interceptors>
然后在 src/main/java/com/itdragon/interceptors 目录下创建 UserLoginHandlerInterceptor.java 文件
package com.itdragon.interceptors;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;
import com.itdragon.pojo.User;
import com.itdragon.service.UserService;
import com.itdragon.utils.CookieUtils;
public class UserLoginHandlerInterceptor implements HandlerInterceptor {
public static final String COOKIE_NAME = "USER_TOKEN";
@Autowired
private UserService userService;
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
throws Exception {
String token = CookieUtils.getCookieValue(request, COOKIE_NAME);
User user = this.userService.getUserByToken(token);
if (StringUtils.isEmpty(token) || null == user) {
// 跳转到登录页面,把用户请求的url作为参数传递给登录页面。
response.sendRedirect("http://localhost:8081/login?redirect=" + request.getRequestURL());
// 返回false
return false;
}
// 把用户信息放入Request
request.setAttribute("user", user);
// 返回值决定handler是否执行。true:执行,false:不执行。
return true;
}
@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
ModelAndView modelAndView) throws Exception {
}
@Override
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler,
Exception ex) throws Exception {
}
}
可能存在的问题
SpringData 自动更新问题
SpringData 是基于Hibernate的。当User 已经是持久化对象,被保存在session缓存当中。若User又重新修改属性值,在提交事务时,此时hibernate对象就会拿当前这个User对象和保存在session缓存中的User对象进行比较,如果两个对象相同,则不会发送update语句,否则,会发出update语句。
笔者采用比较傻的方法,就是在提交事务之前把数据还原。各位如果有更好的办法请告知,谢谢!
参考博客:http://www.cnblogs.com/xiaoluo501395377/p/3380270.html
检查用户信息是否保存
登录成功后,进入Redis客户端查看用户信息是否保存成功。同时为了方便测试,也可以删除这个key。
[root@localhost bin]# ./redis-cli -h 192.168.225.131 -p 6379
192.168.225.131:6379>
192.168.225.131:6379> keys *
1) "REDIS_USER_SESSION:1d869ac0-3d22-4e22-bca0-37c8dfade9ad"
192.168.225.131:6379> get REDIS_USER_SESSION:1d869ac0-3d22-4e22-bca0-37c8dfade9ad
"{\"id\":3,\"account\":\"itdragon\",\"userName\":\"ITDragonGit\",\"plainPassword\":null,\"password\":null,\"salt\":null,\"iphone\":\"12349857999\",\"email\":\"itdragon@git.com\",\"platform\":\"github\",\"createdDate\":\"2017-12-22 21:11:19\",\"updatedDate\":\"2017-12-22 21:11:19\"}"
总结
1 单点登录系统通过将用户信息放在Redis数据库中实现共享Session效果。
2 Java 配置方式使用四个注解 @Configuration @Bean @PropertySource @Value 。
3 Spring 拦截器的设置。
4 HttpClient 的使用。
5 祝大家圣诞节快乐!
源码: https://github.com/ITDragonBlog/daydayup/tree/master/SpringBoot-SSO
到这里,基于SpringBoot的单点登录系统就结束了,有什么不对的地方请指出。
单点登录系统实现基于SpringBoot的更多相关文章
- 单点登录系统(SSO)之CAS(中央认证服务)
SSO(Single Sign On)单点登录系统,是在多个系统中值要求只要登录一次,就可以用已登录的身份访问多个系统,去掉了每次访问不同的系统都要重新登录的弊端. CAS(中央/集中认证服务):Th ...
- 单点登录系统(SSO)的开发思路
单点登录并不是一个新鲜的玩意儿,比较官方的解释是企业业务整合的解决方案之一,通俗来讲SSO就是一个通用的用户中心,国内比较流行的UCenter就是一套单点登录解决方案.而近期以CSDN明文存储用户密码 ...
- 多平台的网站实现单点登录系统(SSO)的开发思路 让你的会员中心更加统一(参考资料)
单点登录并不是一个新鲜的玩意儿,比较官方的解释是企业业务整合的解决方案之一,通俗来讲SSO就是一个通用的用户中心,国内比较流行的UCenter就是一套单点登录解决方案.而近期以CSDN明文存储用户密码 ...
- e3mall商城的归纳总结10之freemarker的使用和sso单点登录系统的简介
敬给读者的话 本节主要讲解freemarker的使用以及sso单点登录系统,两种技术都是比较先进的技术,freemarker是一个模板,主要生成一个静态静态,能更快的响应给用户,提高用户体验. 而ss ...
- 教你开发asp.net的单点登录系统
单点登录系统,简称SSO.以下是我花了几个小时写的一个简单实现.特把实现思路和大家分享. 背景:某项目使用ASP.NET MemberShip来做会员系统,需要同时登录多个系统.而项目的开发人员无法在 ...
- CAS单点登录系统整合——注册的问题
最近一段时间在搞CAS单点登录系统,涉及到几个子系统的整合问题.对于注册,这里遇到了一个选择: 在子系统内完成注册,然后把信息同步到CAS系统: 在CAS系统中完成基本信息的注册,比如:用户名.邮箱. ...
- SSO - 我们为何需要单点登录系统
SSO,Single Sign On,也就是单点登录,保证一个账户在多个系统上实现单一用户的登录 现在随着网站的壮大,很多服务会进行拆分,会做SOA服务,会使用dubbo做微服务,或者简单的小型分布式 ...
- 八幅漫画理解使用JSON Web Token设计单点登录系统
用jwt这种token的验证方式,是不是必须用https协议保证token不被其他人拦截? 是的.因为其实只是Base64编码而已,所以很容易就被解码了.如果你的JWT被嗅探到,那么别人就可以相应地解 ...
- 单点登录系统CAS筹建及取得更多用户信息的实现
国内私募机构九鼎控股打造APP,来就送 20元现金领取地址:http://jdb.jiudingcapital.com/phone.html内部邀请码:C8E245J (不写邀请码,没有现金送)国内私 ...
随机推荐
- 师兄带你轻松入门GitHub
小白:师兄,师兄,我最近总是听到Github,看起来好高大上那,可是不懂是做什么得那? 师兄:你知道微博吧,Github就是程序员的微博,你可以在这里看到全世界最优秀的程序员在做什么. 小白:师兄就是 ...
- 从零开始一起学习SLAM | 点云平滑法线估计
点击公众号"计算机视觉life"关注,置顶星标更快接收消息! 本文编程练习框架及数据获取方法见文末获取方式 菜单栏点击"知识星球"查看「从零开始学习SLAM」一 ...
- 必须添加对程序集"System.Core"的引用
在项目下的web.config中添加 <compilation debug="true" targetFramework="4.0"> <as ...
- Kubernetes外挂配置管理—ConfigMap介绍
目录贴:Kubernetes学习系列 其他容器编排调度工具会大谈特谈“轻应用”.“十二要素应用”,这样就势必会对企业级复杂应用做很大的改动.Kubernetes是为了解决“如何合理使用容器支撑企业级复 ...
- java 常用的异常处理
在Java中异常被当做对象来处理,根类是java.lang.Throwable类,在Java中定义了很多异常类(如OutOfMemoryError.NullPointerException.Index ...
- BIOS备忘录之IIC(touchpad)设备
简述BIOS中对IIC device的支持,以touchpad为例. 信息收集 收集平台的硬件信息: 1. IIC controller number(PCH一般包含多个controller,我们使用 ...
- windows下python操作mysql模块安装
百度教程说安装 pip install mysqldb 这在我的电脑上安装失败: Could not find a version that satisfies the requirement mys ...
- UTF-8格式txt文件读取字节前三位问题
今天试着读取一份UTF-8格式的txt文件,内容如下 12345 但是每次读取之后转为String类型,输出字符串长度总是为6,并且第一位打印在控制台后不占任何空间. 经过debug查看字节码后发现, ...
- Sublime text 3 For LINUX 注册方法&关闭更新提示
在 /etc/hosts 文件加入以下 127.0.0.1 www.sublimetext.com 127.0.0.1 license.sublimehq.com 然后再Sublime输入以下注册码 ...
- jQuery validator plugin之Validator
Validator.destroy() Destroys this instance of validator freeing up resources and unregistering event ...