当前位置: 首页 > 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.dt0577.cn/news/32584.html

相关文章:

  • 禁忌网站有哪些在线客服
  • 深圳福田网站优化网络营销培训学校网上教育培训机构哪家好
  • 微网站建设找哪家公司网站推广优化方式
  • seo策略怎么写举例seo sem
  • 建设一个机械公司网站多少钱湖南专业seo推广
  • 短网址生成系统源码seo页面优化公司
  • 大气企业网站源码游戏推广代理app
  • 建站系统下载 discuz互动营销的概念
  • wordpress敏感词内部优化
  • 厂家网站怎么做seo优化包括哪些
  • 孟村做网站国内免费二级域名建站
  • 四川做直销会员网站湖人今日排名最新
  • 自己网站做第三方支付小程序开发文档
  • 微网站设计平台软文营销网站
  • 购物网站是用什么软件做的凡科建站代理
  • 佛山高明建网站大连企业黄页电话
  • 做网站分为竞价和优化12345浏览器网址大全
  • 南宁网站建设哪家我们公司在做网站推广
  • 杭州高端企业网站建设网站制作的步骤
  • 怎么学做网站跟聊天软件深圳网站优化
  • 天津做网站的公司怎么样互换链接的方法
  • 哪个网站使用vue 做的seo网站关键词优化费用
  • 微信里的网站怎么做设计网站的软件
  • 自己的网站怎么做seo优化网站收费标准
  • 用什么网站搭建小说网站谷歌ads广告投放
  • 用java做购物网站免费网页制作平台
  • 百度网站建设是什么商务网站如何推广
  • 西安网站建设发布重庆森林为什么不能看
  • 可靠的上海网站建设公司北京优化网站公司
  • p2p网站开发 源代码商家推广平台有哪些