gpt4 book ai didi

java - Oauth 保护的休息 API 无需持有者 token 即可工作

转载 作者:行者123 更新时间:2023-12-01 17:39:22 24 4
gpt4 key购买 nike

Rest 端点受 OAuth 保护,但由于某种原因,我可以在没有 token 的情况下访问 /users/user。请让我知道缺少什么。

在我的资源类中,我提到了以下配置来保护端点。

@Override
public void configure(HttpSecurity http) throws Exception {
http.
anonymous().disable()
.authorizeRequests()
.antMatchers("/users/**")
.access("hasRole('ADMIN')")
.and()
.exceptionHandling()
.accessDeniedHandler(new OAuth2AccessDeniedHandler());
}

最佳答案

也许需要更多信息,但试试这个:

@Override public void configure(HttpSecurity http) throws Exception { 
http.authorizeRequests()
.antMatchers("/users*//**").access("hasRole('ADMIN')")
.and().exceptionHandling()
.accessDeniedHandler(new OAuth2AccessDeniedHandler());
}

or original pattern "/users/**"

关于java - Oauth 保护的休息 API 无需持有者 token 即可工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60988685/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com