我一直在关注如何使用 Springboot 设置安全性的教程。有人可以向我解释一下这条线的作用吗:
.oauth2ResourceServer((oauth2) -> oauth2
.jwt(Customizer.withDefaults())
)
它只是确保 Bearer 令牌是 JWT 格式吗?或者它是否真的联系Google(我用它来登录)来验证JWT令牌
它位于: @豆 public SecurityFilterChain filterChain(HttpSecurity http) 抛出异常 {
http
.authorizeHttpRequests(request -> request
.requestMatchers("/api/secure/**")
.authenticated()
.anyRequest().permitAll())
.oauth2ResourceServer((oauth2) -> oauth2
.jwt(Customizer.withDefaults())
)
.sessionManagement((session) ->
session.sessionCreationPolicy(SessionCreationPolicy.STATELESS)
)
.cors(Customizer.withDefaults()
);
http.csrf(csrf->csrf.disable());
return http.build();
}