栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

在单个Web应用程序路径上进行spring-boot设置基本身份验证?

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

在单个Web应用程序路径上进行spring-boot设置基本身份验证?

我不确定登出,但是我们有一些类似的问题,即我们的某些网站处于基本状态,而有些则没有。我们的解决方案是仅对需要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上,而其他端点则使用自定义身份验证令牌头。我们不要求提供凭据(没有发出挑战),尽管有任何其他要求。我们必须注册一些其他内容才能实现(如果需要的话)。

希望这可以帮助



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/435467.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号