我不确定登出,但是我们有一些类似的问题,即我们的某些网站处于基本状态,而有些则没有。我们的解决方案是仅对需要http
basic的路径使用第二个嵌套配置类。我们给这个配置一个@Order(1)..但是我不确定这是否必要。
用代码更新
@Configuration@EnableWebMvcSecurity@EnableGlobalMethodSecurity(prePostEnabled = true)public class SecurityConfig { private static final Logger LOG = LoggerFactory.getLogger(SecurityConfig.class); @Autowired public void registerAuthentication(AuthenticationManagerBuilder auth, Config appConfig) throws Exception { auth.inMemoryAuthentication() .withUser(appConfig.getString(APIConfig.CONFIG_KEY_MANAGEMENT_USER_NAME)) .password(appConfig.getString(APIConfig.CONFIG_KEY_MANAGEMENT_USER_PASS)) .roles(HyperAPIRoles.DEFAULT, HyperAPIRoles.ADMIN); } @Configuration @Order(1) public static class ManagerEndpointsSecurityConfig extends WebSecurityConfigurerAdapter { @Override protected void configure(HttpSecurity http) throws Exception { http .antMatcher("/management @Configuration public static class ResourceEndpointsSecurityConfig extends WebSecurityConfigurerAdapter { @Override protected void configure(HttpSecurity http) throws Exception { http //fyi: This adds it to the spring security proxy filter chain .addFilterBefore(createBBAuthenticationFilter(), BasicAuthenticationFilter.class) ; } }}
这似乎可以通过基本身份验证将执行器端点保护在/
management上,而其他端点则使用自定义身份验证令牌头。我们不要求提供凭据(没有发出挑战),尽管有任何其他要求。我们必须注册一些其他内容才能实现(如果需要的话)。
希望这可以帮助
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)