【发布时间】:2020-12-19 02:21:24
【问题描述】:
我正在尝试编写有关 Spring Security 和 OAuth2、Spring boot 1.5 的教程 https://www.tutorialspoint.com/spring_boot/spring_boot_oauth2_with_jwt.htm。我可以获得访问令牌。但是当我尝试获取端点时,我在 Postman 中收到拒绝访问错误。我正在使用 Mac 操作系统。
配置方法
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests().anyRequest().authenticated().and().sessionManagement()
.sessionCreationPolicy(SessionCreationPolicy.NEVER);
}
在 tokenEnhancer 方法中我注释了公钥,因为我有一个关于 Mac 验证的错误
@Bean
public JwtAccessTokenConverter tokenEnhancer() {
JwtAccessTokenConverter converter = new JwtAccessTokenConverter();
converter.setSigningKey(privateKey);
//converter.setVerifierKey(publicKey);
return converter;
}
【问题讨论】:
-
403 错误表示用户已通过身份验证但无权访问。用户未授权。你能展示你的 configure(HttpSecurity http) 方法吗?
标签: spring-boot spring-security oauth-2.0 jwt postman