当前位置: 首页 > 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.rkmt.cn/news/47996.html

相关文章:

  • 使用cline集成aws的mcp服务和搜索功能
  • Emacs中文等宽字体设置(要用英文名称,系统中的名称)
  • 102302134陈蔡裔数据采集第三次作业
  • Pandas - How to know which columns of a dataframe has null value?
  • 三分法
  • 昆仑通态触摸屏物联网远程运维McgsIot
  • 微软MS17-012安全更新详解:六大Windows漏洞修复指南
  • 以太坊的测试网络 - all-in
  • *题解:P6617 查找 Search
  • C 指针数组函数之间的关联
  • 逻辑回归(随笔)
  • 这封邮件写得真好,是你自己写的吗? 不,是AI写的
  • 灵活用工-连续劳务-计算器工具类,拿走不谢
  • Scapy构建telnet包
  • 逻辑回归原理与案例分析
  • 杂题记录 4
  • 25年11月计数题做题记录
  • CCPC2025哈尔滨站-H. 匹配
  • 【做题记录】HZOJ 多校-数论
  • 2014 吉林省赛题解 | CCUT应用OJ题解——F[X] + X = N
  • 洛谷 P4859 已经没有什么好害怕的了 题解(DP,二项式反演)
  • 飞鱼uu单人防空4
  • HaluMem:揭示当前AI记忆系统的系统性缺陷,系统失效率超50%
  • 团队作业2-需求规格说明书
  • 25.11.12 差分约束算法
  • 11/12
  • 解决Cursor编辑器无法通过include path识别C++头文件的问题
  • 重组蛋白基础与技术概述
  • Dynamics 365 Field Service跨站脚本欺骗漏洞分析
  • 日报11.12