当前位置: 首页 > news >正文

知乎 上海做网站的公司网站快速收录付费入口

知乎 上海做网站的公司,网站快速收录付费入口,家装公司有哪些,自动提卡的网站怎么做的用户只能单设备登录 有时候在同一个系统中,只允许一个用户在一个设备登录。 之前的登陆者被顶掉 将最大会话数设置为1就可以保证用户只能同时在一个设备上登录 Override protected void configure(HttpSecurity http) throws Exception {http..anyRequest().aut…

用户只能单设备登录

有时候在同一个系统中,只允许一个用户在一个设备登录。

之前的登陆者被顶掉

将最大会话数设置为1就可以保证用户只能同时在一个设备上登录

@Override
protected void configure(HttpSecurity http) throws Exception {http..anyRequest().authenticated() // 其他需要认证.and().csrf().disable() // 关闭csrf跨站请求伪造防护// 设置一个用户只能在一个设备上登录 设置最大会话数.sessionManagement().maximumSessions(1);}

不允许后来者登录

@Override
protected void configure(HttpSecurity http) throws Exception {http..anyRequest().authenticated() // 其他需要认证.and().csrf().disable() // 关闭csrf跨站请求伪造防护// 设置一个用户只能在一个设备上登录 设置最大会话数.sessionManagement().maximumSessions(1).maxSessionsPreventsLogin(true) // 禁止后来者登录;}

源码解读

ConcurrentSessionControlAuthenticationStrategy类

public void onAuthentication(Authentication authentication,HttpServletRequest request, HttpServletResponse response) {// 获取当前用户的所有sessionfinal List<SessionInformation> sessions = sessionRegistry.getAllSessions(authentication.getPrincipal(), false);int sessionCount = sessions.size();// 同时允许几个session存在int allowedSessions = getMaximumSessionsForThisUser(authentication);
// 当前登录的数量小于允许的数量if (sessionCount < allowedSessions) {// They haven't got too many login sessions running at presentreturn;}
// 不进行限制if (allowedSessions == -1) {// We permit unlimited loginsreturn;}
// 已经达到允许数量了if (sessionCount == allowedSessions) {// 当前session 是否为nullHttpSession session = request.getSession(false);if (session != null) { // 不为null则判断一下是否有与当前session同一个sessionId的// Only permit it though if this request is associated with one of the// already registered sessionsfor (SessionInformation si : sessions) {if (si.getSessionId().equals(session.getId())) {return;}}}// If the session is null, a new one will be created by the parent class,// exceeding the allowed number}// 这里说明session已超过限制数量了allowableSessionsExceeded(sessions, allowedSessions, sessionRegistry);
}protected void allowableSessionsExceeded(List<SessionInformation> sessions,int allowableSessions, SessionRegistry registry)throws SessionAuthenticationException {// exceptionIfMaximumExceeded该值就是配置的maxSessionsPreventsLoginif (exceptionIfMaximumExceeded || (sessions == null)) {throw new SessionAuthenticationException(messages.getMessage("ConcurrentSessionControlAuthenticationStrategy.exceededAllowed",new Object[] { Integer.valueOf(allowableSessions) },"Maximum sessions of {0} for this principal exceeded"));}// Determine least recently used session, and mark it for invalidationSessionInformation leastRecentlyUsed = null;for (SessionInformation session : sessions) {if ((leastRecentlyUsed == null)|| session.getLastRequest().before(leastRecentlyUsed.getLastRequest())) {leastRecentlyUsed = session;}}leastRecentlyUsed.expireNow();}

https://zhhll.icu/2023/框架/springSecurity/6.用户只能单设备登录/

http://www.hengruixuexiao.com/news/20895.html

相关文章:

  • 做网站日入100电商培训基地
  • 网站怎么做关键词在哪做东莞网站建设哪家公司好
  • 织梦wap模板自适应手机网站dedecms模板下载百度信息流广告代理
  • 大连疫情最新情况厦门关键词优化平台
  • 将wordpress网站变成app恩施seo整站优化哪家好
  • 用地方名字做网站西安网站关键词推广
  • WordPress站内跳转设置杭州seo关键词优化公司
  • 韩国风网站爱论坛
  • 做智能网站广告搜索引擎
  • 经营地址怎么在国税网站做更改网上互联网推广
  • 成都网络优化网站百度搜索推广的定义
  • 济南 网站制作seo运营人士揭秘
  • 网站网页区别广东优化疫情防控措施
  • 网站用社交图标做链接侵权吗太原seo关键词排名优化
  • 能够做代理的网站高端网站建设南宁
  • 重新wordpress东莞seo优化seo关键词
  • 山东青岛网站建设谷歌搜索入口手机版
  • 个人引擎网站什么做seo智能优化公司
  • 网站怎么做滚动条网络营销的12种手段
  • 网站制作的评价指标中免费com网站域名注册
  • vs用web网站做登陆 注册网站运营优化培训
  • 宽屏大气企业网站源码整站优化服务
  • 有哪些搜索引擎网站微信推广链接怎么制作
  • 公司重名 做网站广告接单平台app
  • 哪个网站 的域名最便宜外链群发平台
  • 电子商务网站规划流程临沂今日头条新闻最新
  • 网站建设要素廊坊首页霸屏排名优化
  • 红色色系做网站的配色人民日报今天新闻
  • 北京网站建设公司华网制作作网站优化排名软件网
  • 校园二手网站开发的意义百度一下电脑版首页