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

帮人做网站的推广网站建站公司

帮人做网站的推广,网站建站公司,web前端工程师招聘,上海网站排名优化推荐用户只能单设备登录 有时候在同一个系统中,只允许一个用户在一个设备登录。 之前的登陆者被顶掉 将最大会话数设置为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.tj-hxxt.cn/news/61887.html

相关文章:

  • 惠东网站设计网上在哪里打广告最有效
  • 什么网站详情页做的好百度旗下推广平台有哪些
  • 阿克苏网站开发如何做网站 新手 个人 教程
  • 微信企业网站 源码企业营销策划书范文
  • php网站多语言翻译怎么做百度推广竞价是什么意思
  • 网站背景居中怎么做百度指数官网登录
  • 内蒙古住房与城乡建设厅网站网址百度搜索下载app
  • 做的很漂亮的网站seo优化上海牛巨微
  • 网站安全建设模板关键词优化报价怎么样
  • 做直播网站开发教程百度站长工具如何使用
  • wordpress悬浮框上首页seo
  • 做网站游戏总结的例文优化设计六年级上册语文答案
  • 网站建设设计780元全包如何进行电子商务网站推广
  • 广州市网站集约化建设工作要求零基础学seo要多久
  • 移动网站设计上机考试谷歌seo搜索引擎优化
  • 龙岩市住房与城乡建设局网站seo超级外链工具
  • 做毕业设计网站教程搜索引擎收录
  • icp网站信息seo词条
  • wordpress 公告插件长沙seo服务哪个公司好
  • 阿里云上做网站独立站
  • wordpress搭建小说站关键字挖掘
  • 农村电商做什么项目好seo网络推广专员
  • iis添加网站的物理路径crm系统
  • wordpress4.5 火车头湘潭seo培训
  • 管理网站用什么系统好seo顾问服务公司
  • 博罗网站制作公司网站链接交易
  • 做网站能带来什么网络营销公司网络推广
  • 移动应用开发技术有哪些北京seoqq群
  • 可以做单的猎头网站什么是新媒体营销
  • 商务网站建设实训报告1500字互联网营销的特点