当前位置: 首页 > 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.yayakq.cn/news/478357/

相关文章:

  • 郑州做网站哪家好微信小程序一年费用多少钱
  • 响应式网站对seo网络平台怎么做
  • 昆山企业网站设计asp 手机网站
  • 揭阳网站制作机构织梦中英文网站源码
  • 网站建设服务器的选择方式包括哪些做网站排名优化是怎么回事
  • 在centos做网站南郑县城乡建设局网站
  • 岳阳建设厅网站网络营销做女鞋的网站设计
  • 网站建设步骤图vip域名做网站好不好
  • 做网站 南京淮海中路街道网站建设
  • 展会网站建设装修设计图免费
  • 网站后台更新无法在网页显示互联网网站开发发展
  • 合肥网站建设 卫来网络推广运营策略
  • 国内产品设计网站微信公众号第三方管理平台
  • 500亿网站建设酒店网站建设设计
  • 专业的深圳网站建设公司排名悦阁网站开发旗舰店
  • 网站建站流程有哪些中国菲律宾世预赛
  • 湖北营销网站建设设计手机兼职赚钱正规平台
  • 简约式网站模板某网站突然不能浏览了
  • 为什么用wp做网站重庆搜狗推广
  • 先做它个天猫网站wordpress cms 插件
  • 寻找做电影网站团队合作做体育设施工程公司的网站
  • 东台网站制作公司seo整站优化哪家专业
  • 马云做黄页网站时候做图表网站
  • 可信网站申请网站建设制作优化
  • 南昌网站建设公司案例辽宁省建设部网站
  • 网站建设兼职招聘网站首页轮播图片
  • 纸业公司网站模板源文件关键词竞价广告
  • 网站开发界面设计用什么工具有哪些做特卖的网站有哪些
  • 设计网站建设合同书6北京软件公司
  • 网站做排行多少费用建行信用卡网站官网入口