在一个反应性的spring网络流量服务中,我将端点配置为受OAuth2资源服务器的保护。当我第一次启动服务器时,它正确地验证Bearer令牌,但是大约30秒后,相同的请求开始失败,出现以下错误:
error="invalid_token"
error_description="This iss claim is not equal to the configured issuer"
error_uri="https://tools.ietf.org/html/rfc6750#section-3.1"
我已经验证了令牌是有效的,并且iss声明似乎与
我的目标是以以下方式配置Spring安全性:
从私有开始的任何路由都应该通过Spring oauth2ResourceServerAll进行身份验证,其他路由应该是可自由访问的
我已经尝试了下面的代码,但这给了我一个问题,即它也试图验证非私有的其他路由。
@Configuration
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Bean
public PasswordEncoder passwordEncoder() {
return new BCryptPass
我希望我的spring引导应用程序能够为受保护的前端提供服务,同时也是用于上述前端的API资源服务器,但我无法让oauth的内容正常工作。
我想要的是当浏览器请求没有令牌的index.html时,spring引导应用程序返回一个302重定向到oauth服务器(在我的例子中是gitlab),因此用户被发送到登录表单。但是我也希望API在没有令牌的情况下调用时返回401,因为我认为302重定向到登录页面并不是很有用。
在伪码中:
if document_url == /index.html and token not valid
return 302 https//gitlab/loginpa
我还没有找到适当的办法解决我的问题。我正在使用Security Oauth2资源服务器来验证我的请求。效果很好。但是,在不同的情况下测试时,如果不存在授权头,或者如果存在授权头,则spring安全性返回为403,而不是401。如果存在授权头,则该值不会以Bearer开头。
Spring Boot Starter - 2.6.7
Spring Boot Starter Security - 2.6.7
Spring Security Config & Web - 5.6.3
Spring Security Core - 5.3.19
Spring Boot Starter OAuth2
由于我的验证器失败,在尝试解码Jwt时发生错误时,我无法捕获身份验证失败事件。我使用的是Spring Security 5.2.1。请注意,当我根本没有在“authorization”头中传递令牌时,我确实捕获了授权失败事件。我想一些额外的配置必须用spring配置来完成。 抛出异常: org.springframework.security.oauth2.core.OAuth2AuthenticationException: An
error occurred while attempting to decode the Jwt: This aud claim does not
con
我已经将我的spring-boot-starter-parent升级到了最新版本(2.3.3版本),从那以后我就不能构建我的应用程序了。我收到一个错误 Non-resolvable import POM: Failure to find org.codehaus.groovy:groovy-bom:pom:1.8.6 in https://jitpack.io was cached in the local repository, resolution will not be reattempted until the update interval of jitpack.io has e
我用Spring boot创建了一个Spring initializer项目,到目前为止只有初始代码。
样本代码
@SpringBootApplication
public class EcommerceApplication {
public static void main(String[] args) {
SpringApplication.run(EcommerceApplication.class, args);
}
}
@Controller
@RequestMapping(value = "/")
public class H