Spring Security
Spring Security 是一个功能强大的认证与授权框架,支持表单登录、JWT、OAuth2 等多种认证方式。
基本用法:继承 WebSecurityConfigurerAdapter(或使用新的 SecurityFilterChain 配置注册)并配置认证和授权规则。
示例:
java
http
.authorizeHttpRequests(authorize -> authorize
.requestMatchers("/public/**").permitAll()
.anyRequest().authenticated())
.oauth2ResourceServer(oauth2 -> oauth2.jwt());更多配置请参考官方文档。