《Spring in Action》第4章-Spring Security

spring security 超详细使用教程(接入springboot、前后端分离) 如果需要更复杂的授权逻辑,可以实现自定义的或。 阅读详情

Spring Security

开始使用Spring Security

加入依赖

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-security</artifactId>
</dependency>

自动探测Spring Security在classpath中

访问任何页面,将提示输入用户名和密码,默认用户名:user ,密码在启动日志中

不做任何操作我们得到了下列安全特性

  • 所有HTTP请求路径都需要验证
  • 不需要说明角色和权限
  • 一个简单的登录页面
  • 基础的HTTP请求验证
  • 有一个user用户

配置用户仓库

Java-based配置的基本骨架:

import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;

@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {

}

需要@EnableWebSecurity注解,并继承WebSecurityConfigurerAdapter

无论基于那种用户仓库,我们都可以通过覆盖configure()方法来选择用户仓库。

in-memory

适用于如果只有少数用户,且这些用户不需要被修改。

@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
	@Override
       protected void configure(AuthenticationManagerBuilder auth) throws Exception {
           auth.inMemoryAuthentication()
	           .withUser("lrz").password("{bcrypt}$2a$10$6PFq.48e0kB44d2SCY8HoeIacJTAsm0SJQJWtRAPgZJJnY8WYdcqa").authorities("ROLE_USER")
	           .and()
	           .withUser("lrz2").password("{noop}abc123").authorities("ROLE_USER");
       }
}

在Spring Security 5.0之前,默认的密码编码器是NoOpPasswordEncoder,在5.0之后提供了更多的编码器,并要求我们明确的说明编码器。

使用{encodeid}password格式

{bcrypt}$2a$10$dXJ3SW6G7P50lGmMkkmwe.20cQQubK3.HZWzG3YB1tlRy.fqvM/BG
{noop}password
{pbkdf2}5d923b44a6d129f3ddf3e3c8d29412723dcbde72445e8ef6bf3b508fbf17fa4ed4d6b99ca763d8dc
{scrypt}$e0801$8bWJaSu2IKSn9Z9kM+TPXfOc/9bdYSrN1oD9qfVThWEwdRTnO7re7Ei+fUZRJ68k9lTyuTeUp4of4g24hHnazw==$OAOec05+bXxvuu/1qZ6NUR+xQYvYv7BeL1QxwRpY5Pc=  
{sha256}97cde38028ad898ebc02e690819fa220e88c62e0699403e94fff291cfffaf8410849f27605abcbc0

JDBC-based

将用户存储在数据库中

DataSource dataSource;
@Autowired
public SecurityConfig(DataSource dataSource) {
	this.dataSource = dataSource;
}

@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
	auth.jdbcAuthentication().dataSource(dataSource).passwordEncoder(NoOpPasswordEncoder.getInstance());
}

在验证用户时,SpringSecurity会自动查询下面的Sql:

--验证用户
select username,password,enabled from users where username=?
--验证用户权限
select username, authority from authorities where username=?
--查询用户的用户组
select g.id, g.group_name,ga.authority from groups g, group_members gm, group_authorities ga where gm.username=? and g.id = ga.group_id and g.id = gm.gourp_id

一个简单的表构造语句及数据初始化

create table if not exists users(
username varchar(24) not null,
password varchar(128) not null,
enabled int default 1
);

create table if not exists AUTHORITIES(
username varchar(24) not null,
authority varchar(24) not null
);
alter table AUTHORITIES
 add foreign key (username) references users(username);

create table if not exists groups(
id identity PRIMARY KEY,
group_name varchar(24) not null
);

create table if not exists group_member(
id int not null,
username varchar(24) not null
);
alter table group_member
 add foreign key (username) references users(username);

create table if not exists group_authorities(
authority varchar(24) not null,
id int not null
);
alter table group_authorities
 add foreign key (id) references groups(id);

insert into users (username,password,enabled) values('user','password',1);

insert into AUTHORITIES(username,authority) values('user','ROLE_USER');

如果我们有自己的表结构,也可以自己配置查询语句:

@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
	auth.jdbcAuthentication().dataSource(dataSource)
	.usersByUsernameQuery("select name,pwd,enabled from person where name = ?")
	.authoritiesByUsernameQuery("select pname,name from auth where pname = ?")
	.passwordEncoder(NoOpPasswordEncoder.getInstance());
}

在自定义sql中,字段的顺序要与默认sql对应,字段名称不重要。

我们还需要为密码指定编码器,Spring Security提供的编码器有:

  • BCryptPasswordEncoder
  • Pbkdf2PasswordEncoder
  • SCryptPasswordEncoder
  • StandardPasswordEncoder(已不推荐使用)
  • NoOpPasswordEncoder(已不推荐使用)

数据库中存放的密码应该是被编码后的字符串,且该字符串不应该被解码,Spring Security会将我们输入的密码使用指定的编码器编码后与数据库中存放的密码进行比较。

LDAP-base

略。。。

自定义用户服务

创建User实体并实现org.springframework.security.core.userdetails.UserDetails接口

创建UserRepository并定义按名字查找用户的方法(假设使用了JPA)。

创建UserService类并继承UserDetailsService接口实现其LoadUserByUserName方法,该方法实现按名超找用户。

将UserDetailsService注入配置类,并配置:

@Autowired
private UserDetailsService userDetailsService;

@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
   auth.userDetailsService(userDetailsService).passwordEncoder(new BCryptPasswordEncoder());
}

保护Web请求

我们需要覆盖WebSecurityConfigurerAdapter的另一个configure方法,用于配置授权用户的Web请求。

@Override
protected void configure(HttpSecurity http) throws Exception {
}

这个方法为我们提供了一个HttpSecurity对象,通过配置这个对象,我们可以实现:

  1. 应用只处理符合要求(安全条件)的请求
  2. 配置一个自定义登录页面
  3. 允许用户登出
  4. 配置保护跨站请求伪造(cross-site request forgery)

访问控制

我们可以配置请求规则,使得应用只响应具有相关权限的用户的请求。

http.authorizeRequests()
	.antMatchers("/design","/orders").hasRole("USER")
	.antMatchers("/","/**").permitAll();

上面的配置使得只有具有ROLE_USER权限的用户可以访问/design和/orders,所有的用户都可以访问除上面URL的其它所有URL。每个请求都先匹配第一个规则,如果匹配不上,再匹配第二个,第三个…,所以安全规则的顺序十分的重要。

基本访问控制表达式
ExpressionDescription

hasRole(String role)

Returns true if the current principal has the specified role.

For example, hasRole('admin')

By default if the supplied role does not start with 'ROLE_' it will be added. This can be customized by modifying the defaultRolePrefix on DefaultWebSecurityExpressionHandler.

hasAnyRole(String…​ roles)

Returns true if the current principal has any of the supplied roles (given as a comma-separated list of strings).

For example, hasAnyRole('admin', 'user')

By default if the supplied role does not start with 'ROLE_' it will be added. This can be customized by modifying the defaultRolePrefix on DefaultWebSecurityExpressionHandler.

hasAuthority(String authority)

Returns true if the current principal has the specified authority.

For example, hasAuthority('read')

hasAnyAuthority(String…​ authorities)

Returns true if the current principal has any of the supplied authorities (given as a comma-separated list of strings)

For example, hasAnyAuthority('read', 'write')

principal

Allows direct access to the principal object representing the current user

authentication

Allows direct access to the current Authentication object obtained from the SecurityContext

permitAll

Always evaluates to true

denyAll

Always evaluates to false

isAnonymous()

Returns true if the current principal is an anonymous user

isRememberMe()

Returns true if the current principal is a remember-me user

isAuthenticated()

Returns true if the user is not anonymous

isFullyAuthenticated()

Returns true if the user is not an anonymous or a remember-me user

hasPermission(Object target, Object permission)

Returns true if the user has access to the provided target for the given permission. For example, hasPermission(domainObject, 'read')

hasPermission(Object targetId, String targetType, Object permission)

Returns true if the user has access to the provided target for the given permission. For example, hasPermission(1, 'com.example.domain.Message', 'read')

基于SpEL(Spring Expression Language)的访问控制

我们可以只使用access()方法,并向该方法传递SpEl表达式来达到更加细粒度的访问控制

Spring Security扩展的SpEL表达式:

前面我们的访问控制,使用SpEL的实现:

http.authorizeRequests()
	.antMatchers("/design","/orders").access("haseRole('USER')")
	.antMatchers("/","/**").access("permitAll");

配置自定义登录页面

http.formLogin().loginPage("/login");

loginPage方法中传入的是请求登录页面的路径,我们需要处理这样的请求(创建Controller,或者是使用View控制器)。然后我们需要创建自己的登录页面

<form th:action="@{/login}" method="post">
	...
</form>

要注意的是使用post进行表单提交。SpringSecurity默认在/login监听登录请求,且用户名和密码字段名为username,password,我们可以对其进行配置:

http.formLogin().loginPage("/login")
	.loginProcessingUrl("/aauthenticate")
	.usernamePaaarameter("user")
	.passwordParaameter("pwd")

这样,Spring Security将在/authenticate监听登录,且用户名,密码字段名称为user和pwd。

默认情况下,登录成功后,页面会跳转到原先用户想要请求的页面。我们也可以配置登录成功后的默认跳转路径:

http.formLogin().loginPage("/login")
	.loginProcessingUrl("/aauthenticate")
	.usernamePaaarameter("user")
	.passwordParaameter("pwd")
	.defaultSeccessUrl("/design")

通过上面的配置,如果用户直接访问的登录页面,那么用户登录成功后会重定向到/design。还可以defaultSuccessUrl指定第二个入参为true,这样,无论用户在登录前请求的哪个页面,在登录成功后,都会被重定向到/design。

登出

直接以Post方式请求/logou便可以登出。默认登出后重定向到登录页面,我们也可以配置登出后的默认跳转页面

http.logout().logoutSuccessUrl("/")

防护跨站请求伪造

Spring Security内置了CSRF防护,我们只需要在每一个Post请求提交的数据中增加_csrf字段即可。如果使用的是Thymeleaf:

<input type="hidden" name="_csrf" th:value="${_csrf.token}"/>

如果是使用Thymeleaf模板或者是SpringMVC的JSP tag包, 我们甚至不需要显示的声明_csrf,隐藏的_csrf字段会自动添加到form表单中。如果使用Thymeleaf,我们只需要保证<form>元素中有一个属性是Thymeleaf属性即可。如:

<form th:action="@{/login}" method="post">
	...
</form>

我们也可以关闭对CSRF的防护:

http.csrf().disable();

获取登录用户

我们有一下几种方式来确定当前啊用户:

  1. 注入Principal对象到Controller方法中
  2. 注入Authentication对象到Controller方法中
  3. 在security上下文中使用SecurityContextHolder
  4. 使用被@AuthenticationPrincipal注解的方法

Principal对象

@PostMapping
public String processOrder(@Valid Order order, Errors errors, SessionStatus sessionStatus, Principal principal){
	...
	User user = userRepository.findByUserName(principal.getName());
	Orser.setUser(user);
}

Authentication对象

@PostMapping
public String processOrder(@Valid Order order, Errors errors, SessionStatus sessionStatus, Authentication authentication){
	...
	User user = (User)authentication.getPrincipal();//getPrincipal返回的是Object类型的对象,需要强制类型转换
	Orser.setUser(user);
}

@AuthenticationPrincipal

@PostMapping
public String processOrder(@Valid Order order, Errors errors, SessionStatus sessionStatus, @AuthenticationPrincipal User user){
	...
	Orser.setUser(user);
}

SecurityContextHolder

Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
User user = (User)authentication.getPrincipal();

使用这种方式虽然比较繁琐且与Spring Security耦合,但是我们可以在应用的任何地方使用,不仅仅局限于Controller中。

Spring 4 Security MVC 登录登出完整骨架(XML配置版) Spring Security 是 Spring 生态中实现认证与授权的核心框架,其本质是通过 Filter Chain 拦截请求并委托 AuthenticationManager 执行校验。在传统 Spring MVC 架构中,Security 与 DispatcherServlet 协同工作:前者负责安全拦截与会话管理,后者处理控制器分发与视图渲染。这种组合具备强可控性、低侵入性和清晰的调试路径,特别适合遗留系统加固、教学实践及底层机制学习。本文聚焦 Spring 4 原生环境下的最小可行实现——基于 阅读详情

相关推荐

springbootspringsecurity前后端分离(一个小demo)

一个小demo前后端分离的情况下给到前端是否跳转到登录页的标识符

Spring Security 前后端分离

前后端分离指的就是前后端分离部署,前端 调用后端API,后端 返回 JSON格式数据,页面是由前端渲染并展示到浏览器中。Spring Security 涉及到的扩展点: 登录成功处理:AuthenticationSuccessHandler 登录失败处理:AuthenticationFailureHandler 登出成功处理:LogoutSuccessHandler 未登录处理:AuthenticationEntryPoint 鉴权失败处理:AccessDeniedHandler

Markix的博客 4082

Spring Security in Action

Spring Security in Action

SpringBoot+SpringSecurity+JWT

SpringSecurity从入门到精通 课程介绍 0. 简介 1. 快速入门 1.1 准备工作 1.2 引入SpringSecurity 2. 认证 2.1 登陆校验流程 2.2 原理初探 2.2.1 SpringSecurity完整流程 2.2.2 认证流程详解 2.3 解决问题 2.3.1 思路分析 2.3.2 准备工作 2.3.3 实现 2.3.3.1 数据库校验用户 准备工作 核心代码实现 2.3.3.2 密码加密存储 2.3.3.3 登陆接口 2.3.3.4 认证过滤器 2.3.3.5 退出登陆

酷小亚 1504

ssm+springsecurity+angular.js前后分离小练习

基于maven的ssm+springsecurity+angular.js的个人计划前后分离小练习,完成了部分功能,全套的html页面,适合学习ssm整合或者锻炼自己的能力去完善它

SpringBoot+Vue前后端分离,使用SpringSecurity完美处理权限问题

转载他人 https://blog.youkuaiyun.com/u012702547/article/details/79010010 https://blog.youkuaiyun.com/u012702547/article/details/79019510

Spring Security 真正的前后分离实现

点击上方“猿芯”,选择“设为星标”后台回复"1024",有份惊喜送给面试的你原文 https://www.toutiao.com/article/6894532348956803597Spring Security网络上很多前后端分离的示例很多都不是完全的前后分离,而且大家实现的方式各不相同,有的是靠自己写拦截器去自己校验权限的,有的页面是使用themleaf来实现的不是...

487

基于SpringBoot,Spring Security,JWT,Vue & Element 的前后端分离多商户商城管理系统

平台简介: 前端采用Vue、Element UI。 后端采用Spring Boot、Spring Security、Redis & Jwt。 权限认证使用Jwt,支持多终端认证系统。 支持加载动态权限菜单,多方式轻松权限控制。 高效率开发,使用代码生成器可以一键生成前后端代码。 内置功能 用户管理:用户是系统操作者,该功能主要完成系统用户配置。 部门管理:配置系统组织机构(公司、部门、小组),树结构展现支持数据权限。 岗位管理:配置系统用户所属担任职务。 菜单管理:配置系统菜单,操作权限,按钮权限标识等。 角色管理:角色菜单权限分配、设置角色按机构进行数据范围权限划分。 字典管理:对系统中经常使用的一些较为固定的数据进行维护。 参数管理:对系统动态配置常用参数。 通知公告:系统通知公告信息发布维护。 操作日志:系统正常操作日志记录和查询;系统异常信息日志记录和查询。 登录日志:系统登录日志记录查询包含登录异常。 在线用户:当前系统中活跃用户状态监控。 定时任务:在线(添加、修改、删除)任务调度包含执行结果日志。 代码生成:前后端代码的生成(java、html、xml、sql)支持CRU

Spring Security 安全校验前后端分离

Spring Security 是一个专注于向 Java 应用程序提供身份验证和授权的安全框架,在Web环境下,它是借助Filter来实现对请求的校验;因为是一个框架,开发出来的目的是为了适配各个不同的场景,各种扩展,再加上框架本身默认的功能是在以template 画html, 以Session做回话管理这种开发模式;不过我们现在都是前后端分离,所以原有的一些功能就不怎么适用了,导致我们刚接手时会觉得有点困难,接下来我们简单讲解一下框架的流程,以及后续更改为前后端使用Token交互的方式;

weixin_44084735的博客 2297

H3C ACL的应用与配置1

SWHC1-acl-ipv4-adv-3000]rule 30 permit ip source 192.168.50.252 0 destination 192.168.70.252 0 //设置一条ID为30的过滤,允许源地址为 192.168.50.252 访问目的地址为192.168.70.252 的设备。高级ACL范围3000-3999:对源IP,目地IP,协议,端口号进行过滤。[SWHC1]acl number 3000 //创建高级ACL 3000。

weixin_41120428的博客 2425

WiFi基本概念(六)(L-STF,L-LTF)

L-STF它由10个OFDM symbol(1,0,1,0,1,0,1,0,1,0)构成,每个symbol是0.8us,GI是0.2us,总计10us。Symbol的长度是正常长度的1/4,因此称为Short training field,主要用于快速进行信号检测,信号同步,自动增益控制,接收天线选择(Diversity Selection)。 由于symbol长度是正常的1/4,子载波的宽度是正常的4倍,能进行初略的信道估计,其使用了-24, -20, -16, -12, -8, -4, 4, 8, 1

reekyli的专栏 6863

20210401#《Spring in action 5》

目录

qq_17079255的博客 2116

2026最新YOLO26改进:卷积层、轻量化、注意力机制、损失函数、Backbone、SPPF、Neck、检测头全方位优化汇总

针对YOLO26模型改进痛点,本专栏整理200+实战验证方法,覆盖卷积层、注意力机制等核心模块。 每种方法含原理、性能分析、改进路径及实操流程,代码可直接运行,快速提升模型效果,性价比超高。

魔改工程师的博客 1万+

Spring In Action 5 学习笔记 chapter4 Spring Security部分关键点

spring in action 5 spring security代码实践 bug解决

既然选择了远方,便只顾风雨兼程 1420

10万+字超硬核 机器学习 笔记(面试八股)

10w字总结面试中可能用到的机器学习八股和常用算法,包括感知机(Perceptron)、多层感知机(MLP, Multi-Layer Perceptron)、支持向量机(SVM, Support Vector Machine)、K 最近邻(KNN, K-Nearest Neighbors)、朴素贝叶斯(Naive Bayes)、决策树(Decision Tree)、随机森林(Random Forest)、Bagging、Boosting、GBDT、XGBoos、LightGBM等。

haopinglianlian的博客 4658

PCL 欧式聚类分割【2026最新版】

PCL中欧式聚类提取算法原理详解、代码实现以及一个大自然场景地物分割提取并保存分割结果到本地文件夹的应用案例。

点云侠的博客 40万+

java 8 in action download,Spring实战 第4版(Spring in Action 4th.Edition) pdf英文

资源名称:Spring实战 第4版(Spring in Action 4th.Edition) pdf英文Spring in Action, Fourth Edition is a hands-on guide to the Spring Framework, updated for version 4. It covers the latest features, tools, and prac...

weixin_35633340的博客 424

《基于YOLOv5/8/10的足球比赛球员识别系统毕设全指南:从开发到部署的一站式实战》

本文提出了一个基于YOLO系列模型的足球球员识别系统,具备完整的开发流程和技术方案。系统通过YOLOv5/8/10三大框架实现球员检测,平衡精度与速度需求。开发过程包含数据标注与增强、模型训练调优、PyQt5界面开发等关键环节,并提供了模型轻量化、多任务扩展等优化方向。系统可实现单张图像和视频流的实时识别,支持跨设备部署,适用于赛事分析和训练复盘场景。项目特色在于完整的技术实现路径和对不同YOLO框架的性能对比,为计算机视觉在体育领域的应用提供实践参考。

m0_71589036的博客 216

Spring in Action 5th edition Chapter 4

Chapter 4 How to enable security Config User Authentication Config Url How to get the current user How to enable security add the following dependency <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-b

DarinWang的博客 206

PCL 计算点云AABB包围盒的体积【2026最新版】

AABB包围盒又称了 轴对齐包围盒,是点云包围盒里最简单的一种,其计算方法也极其简单。获取包围盒之后,根据包围盒的长宽高进行体积计算即可!博客长期更新,本文最近一次更新时间为:2026年5月3日。

点云侠的博客 2295

【花雕学编程】Arduino FOC 之AS5048A磁编码器模块

您的硬件平台、使用场景和Arduino版本可能影响使用方法的选择。在Arduino平台上实现FOC可以提供平滑的运行和高度的扭矩、速度和位置控制,它通过精确控制电机的电流和电压来实现高效率、高精度和低噪声的操作。5、创新:Arduino可以让你用电子的方式来表达你的创意和想象,你可以用Arduino来制作各种有趣和有用的项目,如机器人、智能家居、艺术装置等。1、高性能电机控制:FOC是一种高级的电机控制算法,可以精准控制PMSM(永磁同步电机)和BLDC(无刷直流)电机,实现平滑的转速和扭矩输出。

雕爷学编程 1496

Spring Security in Action 第一、二章 第一个Spring Security项目的建立以及基本

Spring Boot是作为Spring框架的应用开发的一个进化阶段出现的。与其说你需要编写所有的配置,不如说Spring Boot已经预设了一些配置,所以你可以只覆盖那些与你的实现不匹配的配置。我们也称这种方法为 “惯例–配置”。在这种开发应用程序的方式存在之前,开发人员为他们必须创建的所有应用程序反复编写几十行代码。在过去,当我们以单体方式开发大多数架构时,这种情况不太明显。在单体架构下,你只需要在开始时写一次这些配置,之后就很少需要再碰它们。当面向服务的软件架构发展起来后,我们开始感受到为配置每个服务

Learning_xzj的博客 1591

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

SPRING IN ACTION: 春天在行动-PART 1

提供有关春天新事物的指南!PART 1 FOUNFATIONAL SPRING

Username1898625 572

lwip-2.0.3

lwip是瑞典计算机科学院(SICS)的Adam Dunkels 开发的一个小型开源的TCP/IP协议栈。实现的重点是在保持TCP协议主要功能的基础上减少对RAM 的占用。

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

Spring Security in Action 第五章 SpringSecurity实现认证

在这一节中,我们将讨论实现自定义认证逻辑。我们分析了与此责任相关的Spring Security合同,以了解其定义。有了这些细节,你就可以通过第5.1.3节中的一个代码例子来实现自定义认证逻辑。Spring Security中的AuthenticationProvider负责处理认证逻辑。AuthenticationProvider接口的默认实现将寻找系统用户的责任交给了UserDetailsService。在认证过程中,它也使用PasswordEncoder进行密码管理。

Learning_xzj的博客 1300

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

MooTool Compose 版 JSON 检查器:JSONPath 查询结果写入「结果」区并对齐 Electron 的实践(DIFF-194)

本文围绕 MooTool 的 JetBrains Compose Desktop 重构版(`next-compose`)中一条架构评审差异记录 DIFF-194 展开:当用户在 JSON 检查器(Inspector)中执行 JSONPath 查询时,查询输出不仅要弹出结果对话框,还必须同步写入会话状态 `session.pathResult`,从而让侧栏「结果」卡片稳定展示查询结果,并与 Elec

gitblog_00713的博客 405

Spring Security- 基于注解的权限控制(@PreAuthorize 等)

传统的权限控制通常依赖于 XML 配置或硬编码在业务逻辑中,这种方式不仅冗长、难以维护,而且容易出错。Spring Security 引入了方法级安全(Method-Level Security),允许开发者直接在方法或类上使用注解来声明访问规则。// 删除用户逻辑上述代码表示:只有拥有ADMIN角色的用户才能调用deleteUser方法。这种声明式风格让安全逻辑与业务逻辑分离,代码更清晰、更易测试。💡方法级安全 vs URL 级安全URL 级安全(如)适用于粗粒度的 Web 层保护;

千淘万漉虽辛苦,吹尽狂沙始到金 1万+
上一篇: 核心技术(卷二)05、第4章-数据库编程
下一篇: 《Spring in Action》第5章-Configuration Properties
风萧水丶寒
博客等级 码龄11年 6粉丝 63原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值