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

Spring Boot 项目安全配置,放行指定规则的 HTTP 请求

 

Spring Boot 项目安全配置,放行指定规则的 HTTP 请求

 

package com.joyupx.config;import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;/*** Spring Security 配置类* //@Order(99)  // 指定唯一的顺序值*/
@Configuration
@EnableWebSecurity
@Order(99)
public class SecurityConfig extends WebSecurityConfigurerAdapter {@Overrideprotected void configure(HttpSecurity http) throws Exception {/*http.formLogin().loginPage("/login").defaultSuccessUrl("/").permitAll().and().logout().permitAll();*/http.authorizeRequests()// 放行所有路径,即不拦截任何 HTTP 请求。.antMatchers("/**").permitAll().anyRequest().authenticated().and().csrf().disable();  // 禁用 CSRF 防护
        }}

 

http://www.jsqmd.com/news/38896/

相关文章:

  • 今晚不加班!我用SpeedAI撸完了一篇1.2万字的初稿 - BUAA
  • 使用cline集成aws的mcp服务和搜索功能
  • Emacs中文等宽字体设置(要用英文名称,系统中的名称)
  • Python 字符串形式与嵌套规则:从 C 语言注释谜题到 Python 引号逻辑
  • Python 字符串格式化全解析:%、format() 与 f-string 的前世今生
  • 20251112 之所思 - 人生如梦
  • Pandas - How to know which columns of a dataframe has null value?
  • 2025年11月13日
  • 三分法
  • vue-element el-select 赋值选择项后选择事件不生效
  • Python正则表达式操作速查表(全面版v1.0 - 2025年11月12日修订)
  • 11月12日日记
  • 微信小程序支付遇到问题:PKIX path building failed: unable to find valid certification path to requested target
  • 11-12午夜盘思
  • Day19综合案例二
  • 命题逻辑连接词 ↔ C++ 逻辑/位运算 对照表(完整版)
  • 昆仑通态触摸屏物联网远程运维McgsIot
  • 简单二分
  • 微软MS17-012安全更新详解:六大Windows漏洞修复指南
  • 2025.11.12总结
  • 以太坊的测试网络 - all-in
  • Scala基础学习day01
  • 洛谷 P11965:[GESP202503 七级] 等价消除 ← 位运算(异或) + STL map
  • C 指针数组函数之间的关联
  • 2025.11.12 测试
  • 13. 罗马数字转化为字符串
  • 这封邮件写得真好,是你自己写的吗? 不,是AI写的
  • FFmpeg 官方汇编课程:写出快 5 倍的视频处理代码
  • 四、中断(基于北京迅为电子)
  • List执行Dispose时可释放子元素逻辑占用的List写法