合集-spring-security源码阅读

摘要:导航页 阅读全文
posted @ 2021-11-15 14:44 意犹未尽 阅读(394) 评论(0) 推荐(0) 编辑
摘要:Form表单登录 默认登录 1.pom配置 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <depende 阅读全文
posted @ 2020-12-10 13:50 意犹未尽 阅读(4603) 评论(0) 推荐(2) 编辑
摘要:部分源码 1.前面一demo的配置是基于内存数据源配置,但是再实际应用中我们都是查库 @Override protected void configure(AuthenticationManagerBuilder auth) throws Exception { /** * inMemoryAuth 阅读全文
posted @ 2020-12-22 16:28 意犹未尽 阅读(404) 评论(0) 推荐(0) 编辑
摘要:说明 在 spring-security使用-登录(一) 我们使用的是重写了Spring-security的filter的方式来进行自定义,但是这样的弊端,就是侵入太大。直接把spring-security的filter给替换掉了, 通过AuthenticationProvider的方式是在spri 阅读全文
posted @ 2021-01-04 17:32 意犹未尽 阅读(5033) 评论(0) 推荐(2) 编辑
摘要:主要是通过Authentication封装 接口定义 public interface Authentication extends Principal, Serializable { //用来获取用户的权限。 Collection<? extends GrantedAuthority> getAu 阅读全文
posted @ 2021-01-05 16:23 意犹未尽 阅读(2072) 评论(0) 推荐(1) 编辑
摘要:自动挤掉前一个用户 1.配置一个用户只允许一个会话 protected void configure(HttpSecurity http) throws Exception { http.authorizeRequests() .anyRequest().authenticated() .and() 阅读全文
posted @ 2021-01-06 16:19 意犹未尽 阅读(2451) 评论(0) 推荐(0) 编辑
摘要:session共享的几种方案 方案一 不放在服务器应用中管理,放在第三方统一管理,如redis,数据库等,现在主流都是放在redis 因为redis高效qps最高能达到10万+ 方案二 session 拷贝,集群情况某一台服务器session发生改变,通知其他服务器,这样会有个问题,如果集群实例太多 阅读全文
posted @ 2021-01-07 11:00 意犹未尽 阅读(2343) 评论(0) 推荐(0) 编辑
摘要:类图 默认提供2种实现 defaultfHttpFirewall 看源码可以看出来比较宽松,我们一般使用StrictHttpFirewall 限制请求方法 如果需要修改可以自定义StrictHttpFirewall public class StrictHttpFirewall implements 阅读全文
posted @ 2021-01-29 10:22 意犹未尽 阅读(2367) 评论(0) 推荐(0) 编辑
摘要:基于注解 需要配置启用@EnableGlobalMethodSecurity(prePostEnabled = true,securedEnabled = true) prePostEnabled: 确定 前置注解[@PreAuthorize,@PostAuthorize,..] 是否启用 secu 阅读全文
posted @ 2021-11-03 19:27 意犹未尽 阅读(149) 评论(0) 推荐(0) 编辑
摘要:时序图 @startuml participant "security starter" as sb participant "WebSecurityConfiguration" as wc participant "webSecurity" as ws participant "WebSecuri 阅读全文
posted @ 2021-11-04 15:04 意犹未尽 阅读(1447) 评论(0) 推荐(0) 编辑
摘要:1.SecurityFilterChain是由HttpSecurty根据各个config配置生成的Filter SecurityFilterChain是接口,默认实现是由DefaultSecurityFilterChain SecurityFilterChain只充当描述的作用,描述哪些url走这批 阅读全文
posted @ 2024-03-10 14:59 意犹未尽 阅读(100) 评论(0) 推荐(0) 编辑
摘要:FilterChainProxy内部存储了我们各个HttpSecurty生成的SecurityFilterChain。FilterChainProxy实现了ServletFilter接口。只真正的入口 org.springframework.security.web.FilterChainProxy 阅读全文
posted @ 2024-03-10 15:10 意犹未尽 阅读(110) 评论(0) 推荐(0) 编辑
摘要:作用 我们获取当前登录用户信息是根据SecurityContextHolder.getContext()获取的,SecurityContextHolder.getContext()本质是ThreadLocal实现 Spring MVC WebAsyncTask是异步另外一个线程 所以用于保证我们在T 阅读全文
posted @ 2021-11-09 14:15 意犹未尽 阅读(361) 评论(0) 推荐(0) 编辑
摘要:主要是在认证 Filter链执行之前 维护SecurityContextHolder 方便我们后续通过SecurityContextHolder.getContext()获取当前会话用户信息 通过SecurityContextConfigurer初始化 默认设置源码处:https://www.cnb 阅读全文
posted @ 2021-11-09 16:49 意犹未尽 阅读(1007) 评论(0) 推荐(0) 编辑
摘要:提供我们在Filter链 执行之前或者之后往Header写入内容 通过HttpSecurity 可以指定 默认是在之后调用 http.headers().addHeaderWriter() 通过org.springframework.security.config.annotation.web.co 阅读全文
posted @ 2021-11-10 10:39 意犹未尽 阅读(452) 评论(0) 推荐(0) 编辑
摘要:负责处理登出相关逻辑,默认url映射是/logout org.springframework.security.config.annotation.web.configurers.LogoutConfigurer 初始化 默认初始化处https://www.cnblogs.com/LQBlog/p/ 阅读全文
posted @ 2021-11-10 15:22 意犹未尽 阅读(456) 评论(0) 推荐(0) 编辑
摘要:最常用的一中过滤器,用于登录认证 http.formLogin() 初始化 类图 AbstractAuthenticationProcessingFilter负责 认证成功和认证失败的调度 提供抽象方法attemptAuthentication 具体的认证逻辑由子类实现 <1> org.sprin 阅读全文
posted @ 2021-11-10 19:05 意犹未尽 阅读(292) 评论(0) 推荐(0) 编辑
摘要:用于校验session是否过期 过期移除 初始化处:org.springframework.security.config.annotation.web.configurers.SessionManagementConfigurer#configure public void configure(H 阅读全文
posted @ 2021-11-10 20:00 意犹未尽 阅读(420) 评论(0) 推荐(0) 编辑
摘要:对Session控制和管理 配置 @Override protected void configure(HttpSecurity http) throws Exception { http.authorizeRequests() .anyRequest() .authenticated() .and 阅读全文
posted @ 2021-11-11 10:54 意犹未尽 阅读(806) 评论(0) 推荐(0) 编辑
摘要:实现记住密码的自动登录,比如session过期 初始化处 org.springframework.security.config.annotation.web.configurers.RememberMeConfigurer RememberMeAuthenticationProvider的作用可以 阅读全文
posted @ 2021-11-11 13:41 意犹未尽 阅读(162) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示