我最近在我的spring boot应用程序中实现了带有spring安全性的JWT身份验证。当对/login的请求到来时,将执行JWTAuthenticationFilter。
public class JWTAuthenticationFilter extends UsernamePasswordAuthenticationFilter {
private AuthenticationManager authenticationManager;
public JWTAuthenticationFilter( AuthenticationManager authenticationManag
由于我的验证器失败,在尝试解码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
我的密钥披风正在返回一个OAuth2AuthenticationToken,但是拒绝添加用户所拥有的角色。相反,它返回的是某种泛型:
Authority: ROLE_USER
Authority: SCOPE_email
Authority: SCOPE_openid
Authority: SCOPE_profile
Java方法是
@GetMapping
public String work_queue(Principal principal, Model model) {
...
//Principal comes in as org.sprin
因此,我试图使用SpringSecurity和JWT令牌来保护api。我可以获得令牌,但是每次尝试使用令牌访问受保护的端点时,我都会得到一个403禁止的令牌。我有一个包含角色和用户的DB。这里是我的spring安全配置:
httpSecurity.csrf().disable().cors().disable()
// dont authenticate this particular request
.authorizeRequests().antMatchers("/authenticate", "/register