SpringBoot项目中的安全框架Shiro和Spring Security—认证、授权等
Shiro
Shiro参考.
一个Java的安全(权限)框架,完成认证、授权、加密,会话管理,Web集成,缓存等。
- Shiro功能
- Shiro架构
Spring Security
SpringSecurity参考.
仅需在项目中引入spring-boot-starter-security模块,进行少量配置,即可实现强大安全管理!
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
三个主要类:
- WebSecurityConfigurerAdapter:自定义Security策略
- AuthenticationManagerBuilder:自定义认证策略
- @EnableWebSecurity:开启WebSecurity模式
其两个主要目标是“认证”和“授权”(访问控制)。
package com.zzh.config;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework