11 2021 档案
摘要:SpringMVC源码阅读-Root WebApplicationContext初始化(一) SpringMVC源码阅读-Servlet WebApplicationContext初始化(二) SpringMVC源码阅读-dispatcher组件初始化过程(三) SpringMVC源码阅读-一个请求
阅读全文
摘要:自定义相关授权注解,正常情况不用自定义。支持el比如 @PostMapping("/create") @Operation(summary = "新增字典数据") @PreAuthorize("@ss.hasPermission('system:dict:create')") public Comm
阅读全文
摘要:默认是跳转页面,针对ajax请求我们需要返回json字符串 自定义认证我认为有2种 一种是登录验证 还有一种是未登录访问需要登录授权的页面 登录认证 一般都是使用默认登录或者继承AbstractAuthenticationProcessingFilter方式可以参考上一篇Spring-Securit
阅读全文
摘要:比如我们有的业务场景需要走outh2 或者短信验证码登录 下面以短信验证码为例 首先梳理默认的登录流程 1.http.formLogin() 会在WebSecurityConfigurerAdapter创建一个FormLoginConfigurer 2.WebSecurityConfigurerAd
阅读全文
摘要:在有些项目中一套系统可能有多套登录逻辑 比如 /manage/** 管理后台相关接口走后台认证 /h5/api/** 小程序相关接口走token认证 在spring-security源码-初始化(九) 1.在"5.WebSecurityConfiguration首先会初始化一个webSecurity
阅读全文
摘要:MethodSecurityInterceptor是Spring Security对于Spring Aop的切入逻辑 @Override public Object invoke(MethodInvocation mi) throws Throwable { //<1>调用方法前的权限校验 Inte
阅读全文
摘要:使用方式参考:https://www.cnblogs.com/LQBlog/p/15505361.html#autoid-0-0-0 使用注解权限需要通过以下方式启用 @EnableGlobalMethodSecurity(prePostEnabled = true,securedEnabled =
阅读全文
摘要:FilterSecurityInterceptor最后一个过滤器,主要做认证和授权拦截,比如我们未登录访问需要登录的页面或者我们配置了授权的页面 http.authorizeRequests() .antMatchers("/hello").hasRole("admin").antMatchers(
阅读全文
摘要:统一的异常处理过滤器,我们可以处理统一的身份认证或者授权的异常 比如未登录访问登录页面 需要认证权限的地方 通过HttpSecurity 可以指定 通过org.springframework.security.config.annotation.web.configurers.ExceptionHa
阅读全文
摘要:实现记住密码的自动登录,比如session过期 初始化处 org.springframework.security.config.annotation.web.configurers.RememberMeConfigurer RememberMeAuthenticationProvider的作用可以
阅读全文
摘要:对Session控制和管理 配置 @Override protected void configure(HttpSecurity http) throws Exception { http.authorizeRequests() .anyRequest() .authenticated() .and
阅读全文
摘要:用于校验session是否过期 过期移除 初始化处:org.springframework.security.config.annotation.web.configurers.SessionManagementConfigurer#configure public void configure(H
阅读全文
摘要:最常用的一中过滤器,用于登录认证 http.formLogin() 初始化 类图 AbstractAuthenticationProcessingFilter负责 认证成功和认证失败的调度 提供抽象方法attemptAuthentication 具体的认证逻辑由子类实现 <1> org.sprin
阅读全文
摘要:负责处理登出相关逻辑,默认url映射是/logout org.springframework.security.config.annotation.web.configurers.LogoutConfigurer 初始化 默认初始化处https://www.cnblogs.com/LQBlog/p/
阅读全文
摘要:提供我们在Filter链 执行之前或者之后往Header写入内容 通过HttpSecurity 可以指定 默认是在之后调用 http.headers().addHeaderWriter() 通过org.springframework.security.config.annotation.web.co
阅读全文
摘要:主要是在认证 Filter链执行之前 维护SecurityContextHolder 方便我们后续通过SecurityContextHolder.getContext()获取当前会话用户信息 通过SecurityContextConfigurer初始化 默认设置源码处:https://www.cnb
阅读全文
摘要:作用 我们获取当前登录用户信息是根据SecurityContextHolder.getContext()获取的,SecurityContextHolder.getContext()本质是ThreadLocal实现 Spring MVC WebAsyncTask是异步另外一个线程 所以用于保证我们在T
阅读全文
摘要:说明 线上出现异常,但是查看节点状态正常,因为使用了容器,挂掉了会重启。因为jvm配置了-XX:HeapDumpOnOutOfMemoryError 参数,出现OMM就会将当时线程和jvm内存情况转存起来可参考:jmv参数配置 排查 1.将运维发过来的hprof导入到 vm 可参考 直通车 3.我们
阅读全文
摘要:时序图 @startuml participant "security starter" as sb participant "WebSecurityConfiguration" as wc participant "webSecurity" as ws participant "WebSecuri
阅读全文
摘要:基于注解 需要配置启用@EnableGlobalMethodSecurity(prePostEnabled = true,securedEnabled = true) prePostEnabled: 确定 前置注解[@PreAuthorize,@PostAuthorize,..] 是否启用 secu
阅读全文