我正在尝试限制Spring boot服务上的特定端点,这取决于它们在OAuth2凭据中设置的角色。 这是端点 @RestController
@RequestMapping("/api/admin")
public class AdminController {
@GetMapping(produces = "application/json")
public TestResponse get() {
return new TestResponse("Admin API Response");
}
}
由于我的验证器失败,在尝试解码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-security开发一个spring应用程序,并使用google登录,但在执行该应用程序时遇到以下错误:
***************************
APPLICATION FAILED TO START
***************************
Description:
Method springSecurityFilterChain in org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration required a
我正在尝试访问服务组件中的HttpServletRequest或HttpSession。服务组件是处理github OAuth2登录的位置。下面是我的服务代码。
@RequiredArgsConstructor
@Service
public class GithubOAuth2UserService implements OAuth2UserService<OAuth2UserRequest, OAuth2User> {
private final UserRepository userRepository;
private final JwtTokenUtil
我正在创建一个spring引导2 OAuth2客户机/服务器应用程序。授权服务器成功登录并重定向到客户端,但当客户端接收重定向()时,客户端浏览器显示:
Your login attempt was not successful, try again.
Reason: [invalid_token_response] An error occurred parsing the Access Token response: The HTTP Content-Type header must be application/json; charset=UTF-8
堆叠痕迹
Authenticati
我还没有找到适当的办法解决我的问题。我正在使用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
按照登录后使用项目Create an OAuth 2.0 Server和Build Your Client App的https://developer.okta.com/blog/2019/03/12/oauth2-spring-security-guide上的示例,访问的任何端点都会跳转到根端点localhost:8082。 我不使用Thymeleaf,因为我的not服务返回的是数据,而不是页面。 OAuth 2.0服务器项目 @SpringBootApplication
@EnableResourceServer
public class Demo2Application {
p