我们使用自定义身份验证过滤器来检查不记名令牌以限制对 /api 的访问
此外,我们允许对 /anonymous
的所有请求
现在我们需要通过不记名令牌为 /admin
添加密钥斗篷授权
我尝试了很多变体,但似乎没有一种在所有 3 种方式中都有效
任何人都可以帮助配置应该是什么样子吗?
现在 configure() 方法看起来像
http
.cors()
.and()
.csrf()
.disable()
.exceptionHandling()
.authenticationEntryPoint(unauthorizedHandler)
.and()
.sessionManagement()
.sessionCreationPolicy(SessionCreationPolicy.STATELESS)
.and()
.authorizeRequests()
.antMatchers("/anonymous/**").permitAll()
.anyRequest()
.authenticated();
http.addFilterBefore(jwtAuthenticationFilter(), UsernamePasswordAuthenticationFilter.class);