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

镇平县两学一做网站南京代做网站制作

镇平县两学一做网站,南京代做网站制作,安踏网站建设策划方案,WordPress商用收费吗用户只能单设备登录 有时候在同一个系统中,只允许一个用户在一个设备登录。 之前的登陆者被顶掉 将最大会话数设置为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.yayakq.cn/news/280663/

相关文章:

  • 广东手机网站开发多少google play
  • 网站的建设分析为网站做外链的方式
  • 做美食哪些类型网站打开自己的网站是别人的域
  • 网站备案查询网站怎么开微商城网店步骤
  • 网站开发培训广西有没有专门做兼职的网站
  • 江苏省教育现代化建设水平监测网站优设网官网首页
  • 网站建设不能持续消费?专门做包装的网站
  • 建设个人网站用到的技术天津建设工程信息网 官网首页
  • 如何自助建网站盐城网站建设找宇
  • 做视频赚钱的好网站403网站打开免费
  • 平度做网站怎么让别人访问自己的网页
  • 微信做网站的弊端dede网站源码 如何修改
  • 网站后台使用说明做网站需要懂程序吗
  • 备案过的网站换域名浏阳商务局网站溪江农贸市场建设
  • 外贸营销员秦皇岛seo排名
  • 天津站设计单位网站建设市场行情
  • 做土特产的网站有哪些做特卖的购物网站
  • 江苏网站开发建设国之珍微站个人网站
  • 建设网站比较好的公司吗网上如何赚钱
  • 河南省住房建设厅网站10分钟免费建网站
  • 网站搜索引擎优化的基本内容南京网站设计公司济南兴田德润简介图片
  • 建设企业网站报价黑龙江专业建站
  • html嵌入网站南宁 江苏建设工程信息网站
  • 网站维护进不去怎么办团购网站营销方案
  • 学网页制作的网站专业恶意点击软件
  • 重庆网站建设齐重庆零臻科技国产免费crm系统有哪些
  • 网站开发搜索功能wordpress 主题模板下载失败
  • 青岛专业网站建设推广报价数字营销策略有哪些
  • 酷站是什么网站网站建设丶金手指下拉11
  • 网站开发的价格seo关键词排名优化价格