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

springsecurity快速入门

Spring Security 是一个功能强大且高度可定制的安全框架,主要用于保护基于 Spring 的应用程序。它提供了一整套用于身份验证、授权、加密、会话管理等功能的工具和 API,从而帮助开发者快速、有效地保护应用程序。
在这里插入图片描述
在这里插入图片描述

@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {@Overrideprotected void configure(HttpSecurity http) throws Exception {http.authorizeRequests().antMatchers("/", "/home").permitAll().anyRequest().authenticated().and().formLogin().loginPage("/login").permitAll().and().logout().permitAll();}@Overrideprotected void configure(AuthenticationManagerBuilder auth) throws Exception {auth.inMemoryAuthentication().withUser("user").password("{noop}password").roles("USER");}
}

在这里插入图片描述

<http><intercept-url pattern="/" access="permitAll" /><intercept-url pattern="/admin/**" access="hasRole('ADMIN')" /><form-login login-page="/login" /><logout logout-url="/logout" />
</http><authentication-manager><authentication-provider><user-service><user name="user" password="password" authorities="ROLE_USER" /></user-service></authentication-provider>
</authentication-manager>

在这里插入图片描述


http://www.mrgr.cn/news/18106.html

相关文章:

  • Unity URP支持多光源阴影
  • 苹果11月推出新款M4 Mac:Mac mini设计焕新 MacBook Pro仅例行更新
  • 小哥进小区难进门难,此现状如何破局?
  • 哪种类型的蓝牙耳机更适合运动?可以闭眼入的开放式耳机推荐
  • H3C交换机native VLAN设置
  • JVM面试(二)内存区域划分
  • Android kotlin使用Netty网络框架实践(客户端、服务端)
  • 搭建核心架构网络项目(局域网)
  • 代码随想录 -- 栈与队列 -- 滑动窗口最大值
  • 20240903 每日AI必读资讯
  • vue2.0中ts中vuex模块化如何使用
  • 完美解决LBP2900打印机安装驱动提示无法识别USB及连接错误等问题(附Win11全新安装支持及卸载方案)
  • 【GeoSceneWebAdaptor】
  • Cobalt Strike 4.8 用户指南-第五节-获取初始访问
  • Java 技术教程:@JsonInclude(JsonInclude.Include.NON_EMPTY) 注解详解
  • 情感分析——中文金融情感词典
  • CommonJS与ESModule标准
  • redisson RMap和RMapCache的区别
  • 2024年,人工智能行业哪些证书权威?
  • 【微信小程序入门】2、微信小程序开发前准备