您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

如何仅在受保护的端点上应用spring安全过滤器?

如何仅在受保护的端点上应用spring安全过滤器?

我有一个具有相同要求的应用程序,要解决此问题,我基本上将Spring Security限制为给定的ant match模式(使用antMatcher),如下所示:

http.antMatcher("/api/**").authorizeRequests() //
        .anyRequest().authenticated() //
        .and()
        .addFilterBefore(authenticationTokenFilterBean(), UsernamePasswordAuthenticationFilter.class);

你可以阅读以下内容http仅在与/api/**授权any requestauthenticated用户的ant模式匹配的请求上调用这些配置and add filter authenticationTokenFilterBean() before UsernamePasswordAuthenticationFilter。对于所有其他请求,此配置无效。

Java 2022/1/1 18:19:20 有352人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶