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

神华科技 网站建设南昌广告制作

神华科技 网站建设,南昌广告制作,wordpress整合问答系统,做一个招聘网站需要多少钱SpringSecurity6从入门到实战之SpringSecurity6自定义认证规则 Spring Security 中默认所有的 http 请求都需要先认证通过后#xff0c;才能访问。那么#xff0c; 如何指定不需要认证就可以直接访问的资源呢#xff1f;比如 用户的登录页面和注册页面#xff0c;都是不需要…SpringSecurity6从入门到实战之SpringSecurity6自定义认证规则 Spring Security 中默认所有的 http 请求都需要先认证通过后才能访问。那么 如何指定不需要认证就可以直接访问的资源呢比如 用户的登录页面和注册页面都是不需要认证就必须能被直接访问的。这就需要设置自定义的URL认证规则 SpringSecurity5.x自定义认证与6.x # 在 SpringSecurity5.x中 了解已被废弃 // 自定义配置类 继承 WebSecurityConfigurerAdapter 类覆盖 configure() 方法Configurationpublic class WebSecurityConfigurer extends WebSecurityConfigurerAdapter {Overrideprotected void configure(HttpSecurity http) throws Exception {http.authorizeHttpRequests().mvcMatchers(/hello).permitAll().anyRequest().authenticated().and().formLogin();}} # 在 SpringSecurity6.x 中// 自定义配置类 使用注解 EnableWebSecurity 配置 SpringSecurity开发示例 创建一个新的controller /test package com.example.controller;import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController;RestController public class HelloController {RequestMapping(/hello)public String hello() {System.out.println(/hello);return hello...;}RequestMapping(/test)public String test() {System.out.println(/test);return test...;} }方便与/hello对比进行测试 根据SpringSecurity6.x自定义认证规则配置 新建MyWeSecurityConfig自定义配置类 package com.example.config;import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.web.SecurityFilterChain;Configuration EnableWebSecurity public class MyWeSecurityConfig {Beanpublic SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {//放行hello和testhttp.authorizeHttpRequests().requestMatchers(/hello, test).permitAll()//所有请求都需要进行认证.anyRequest().authenticated()//进行表单登录验证.and().formLogin();return http.build();} }测试 结论 最终可以发现我们可以自定义认证规则,让例如注册等不需要认证的请求直接放行,让其他请求进行认证操作后再进行放行
http://www.w-s-a.com/news/919699/

相关文章:

  • 兰州做网站客户上海企业在线登记
  • 新乡公司做网站wordpress被大量注册
  • 小语种服务网站公众号平台建设网站
  • 免费做mc皮肤网站企业网站建设合同模板
  • 做网站可以申请个体户么网站的定位分析
  • jsp做的零食网站下载wordpress侧边栏折叠
  • 帝国网站单页做301南京旅游网站建设公司
  • 网站sem优化怎么做网站建设推广安徽
  • 比较好的室内设计网站潍坊网络科技
  • 南宁网站建设公设计联盟网站
  • 多个图表统计的网站怎么做百度推广费2800元每年都有吗
  • 连江县住房和城乡建设局网站企业类网站模版
  • 临沂seo整站优化厂家网站建设 大公司排名
  • 网站开发有哪些方式百度导航怎么下载
  • 网站认证免费视频直播网站建设方案
  • 瀑布流分享网站源代码下载网站构建的一般流程是什么
  • wordpress 4.9 多站wordpress邮箱解析
  • 微信网站开发企业汽车网站设计模板
  • 如何提升网站转化率遵义市公共资源交易平台
  • 网站目录管理模板企业解决方案部
  • 建设网站上申请劳务资质吗珠海哪个公司建设网站好
  • c2c商城网站建设在微信怎么开发公众号
  • 美的公司网站建设的目的做个网站要钱吗
  • 和县建设局网站孟州网站建设
  • 网站与规划设计思路竞价培训课程
  • 网站建设设计视频专业设计企业网站
  • 湖南省建设工程网站cerntos wordpress
  • 主机屋的免费空间怎么上传网站广告公司的经营范围有哪些
  • 门户网站建设公司案例门户建设是什么意思
  • 深圳seo专家东莞网站关键词优化排名