定义配置器

public final class MyFilterConfigurer<H extends HttpSecurityBuilder<H>>
extends SecurityConfigurerAdapter<DefaultSecurityFilterChain, H> { public void configure(H http) throws Exception {
http.addFilterBefore(new MyFilter() , SecurityContextPersistenceFilter.class);
} public static class MyFilter extends GenericFilterBean{ @Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {
System.out.println(request);
chain.doFilter(request, response);
} }
}

配置

@Configuration
public static class WebSecurityConfigurer extends WebSecurityConfigurerAdapter{ @Override
protected void configure(HttpSecurity http) throws Exception {
http
.apply(new MyFilterConfigurer<>())
.and()
.formLogin()
.and()
.logout()
.invalidateHttpSession(true)
.logoutUrl("/logout").logoutSuccessUrl("/")
.logoutRequestMatcher(new AntPathRequestMatcher("/logout"))
.and()
.sessionManagement()
.sessionCreationPolicy(SessionCreationPolicy.IF_REQUIRED)
.and()
.authorizeRequests()
.anyRequest().authenticated();
}
}

Spring-security自定义配置器的更多相关文章

  1. Spring Security自定义认证器

    在了解过Security的认证器后,如果想自定义登陆,只要实现AuthenticationProvider还有对应的Authentication就可以了 Authentication 首先要创建一个自 ...

  2. Spring Security 自定义配置(1)

    @Configuration @EnableWebSecurity public class WebSecurityConfig extends WebSecurityConfigurerAdapte ...

  3. Spring Security认证配置(二)

    学习本章之前,可以先了解下上篇Spring Security基本配置. 本篇想要达到这样几个目的: 1.访问调用者服务时,如果是html请求,则跳转到登录页,否则返回401状态码和错误信息 2.调用方 ...

  4. Spring Security 自定义登录认证(二)

    一.前言 本篇文章将讲述Spring Security自定义登录认证校验用户名.密码,自定义密码加密方式,以及在前后端分离的情况下认证失败或成功处理返回json格式数据 温馨小提示:Spring Se ...

  5. (二)spring Security 自定义登录页面与校验用户

    文章目录 配置 security 配置下 MVC 自定义登录页面 自定义一个登陆成功欢迎页面 效果图 小结: 使用 Spring Boot 的快速创建项目功能,勾选上本篇博客需要的功能:web,sec ...

  6. Spring Security 自定义登录页面

    SpringMVC + Spring Security,自定义登录页面登录验证 学习参考:http://www.mkyong.com/spring-security/spring-security-f ...

  7. spring security自定义指南

    序 本文主要研究一下几种自定义spring security的方式 主要方式 自定义UserDetailsService 自定义passwordEncoder 自定义filter 自定义Authent ...

  8. 解决Spring Security自定义filter重复执行问题

    今天做项目的时候,发现每次拦截器日志都会打两遍,很纳闷,怀疑是Filter被执行了两遍.结果debug之后发现还真是!记录一下这个神奇的BUG! 问题描述 项目中使用的是Spring-security ...

  9. SPRING SECURITY JAVA配置:Web Security

    在前一篇,我已经介绍了Spring Security Java配置,也概括的介绍了一下这个项目方方面面.在这篇文章中,我们来看一看一个简单的基于web security配置的例子.之后我们再来作更多的 ...

  10. Spring Security 入门(1-2)Spring Security - 从 配置例子例子 开始我们的学习历程

    1.Spring Security 的配置文件 我们需要为 Spring Security 专门建立一个 Spring 的配置文件,该文件就专门用来作为 Spring Security 的配置. &l ...

随机推荐

  1. Pagodas 等差数列

    nn pagodas were standing erect in Hong Jue Si between the Niushou Mountain and the Yuntai Mountain, ...

  2. UVA 140_Bandwidth

    题意: 定义一个结点的带宽是其距离所有相连结点的最远距离,一个图的带宽是图中所有结点带宽的最小值.给出一个图中各个结点的相邻情况,要求写出一个结点的排列,使得其所构成的图带宽最小. 分析: 枚举全排列 ...

  3. oracle索引简单使用

    --查询表索引 select * from user_ind_columns where table_name = upper('HY_PROJECT') and column_name = uppe ...

  4. CF # 369 D2 D、E

    D,只要抓住每个点只有一个出度,那么图就能分成几个部分,而且可以发现,一个部分最多一个环. #include <iostream> #include <cstdio> #inc ...

  5. Hadoop-mapreduce 程序在windows上执行需要注意的问题

    1.在主程序中需要添加这几个参数配置 Configuration conf = new Configuration(); // 1.设置job运行时要访问的默认文件系统 conf.set(" ...

  6. 数学之路-python计算实战(21)-机器视觉-拉普拉斯线性滤波

    拉普拉斯线性滤波,.边缘检測  . When ksize == 1 , the Laplacian is computed by filtering the image with the follow ...

  7. 省市联动选择的一个demo,利用vue+webpack+amaze-vue实现省市区联动选择组件

    https://github.com/sunshineJi/vue-city-picker

  8. mac svn cornerstone 破解版资源以及使用方法(仅供学习,非商业使用)

    mac svn 可视化客户端,找了好久,不知道是我搜索的有问题还是怎么了,没有特别好用的. 后来发现了一个大神做的破解版的 cornerstone,具体大神的博客我给忘记了,后续找到会贴出地址,以供膜 ...

  9. fused multiply and add

    1 要解决的问题 计算x*y + z?其中x.y.z都是浮点数. 2 普通的计算方式 e=3; s=4.734612 × e=5; s=5.417242 ----------------------- ...

  10. 【OI】线性筛

    如何查找一个范围内的所有素数? 可以是从1~n挨个判断n%i 是否 == 0,也可以从 1~sqr(n) 一个个判断. 相信你们也听说过埃氏筛法,是使用每一个数的倍数筛掉合数!但是!每一个合数要被筛多 ...