【发布时间】:2023-01-12 04:58:58
【问题描述】:
我有以下...
@RestController
@RequestMapping(path="/person", produces = MediaType.APPLICATION_JSON_VALUE)
public class AuthController {
@GetMapping("")
@ResponseBody
public String getPersonFromEmail(@RequestParam(name = "email") String email){ ... }
}
@EnableWebSecurity
public class SecurityConfig {
...
@Bean
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
http.authorizeHttpRequests()
.requestMatchers("/person").hasAuthority("SCOPE_blahablah")
.anyRequest().authenticated()
.and().cors()
.and().oauth2ResourceServer().jwt();
return http.build();
}
}
当我运行但没有传递令牌时,我得到一个 401。但是,当我传递一个没有适当范围的令牌时,我得到一个 200。我希望也得到一个 403。我错过了什么?
【问题讨论】:
标签: spring-boot oauth auth0