【问题标题】:Spring security open specific paths publicly with OauthSpring security 使用 Oauth 公开打开特定路径
【发布时间】:2017-05-24 05:10:28
【问题描述】:

在我正在开发的 API 中,几乎每条路径都应该受到 oauth 保护,并提供一些示例。现在我设法使用 addFilterBefore 函数保护每条路径:

@Override
protected void configure(HttpSecurity http) throws Exception {
    http.antMatcher("/**")
            .addFilterBefore(zeroLeggedOAuthProviderProcessingFilter, UsernamePasswordAuthenticationFilter.class)
            .authorizeRequests().anyRequest().hasRole("OAUTH");
}

我想做的是为每个人打开一些路径(例如 /languages),同时锁定所有其他路径。

有人可以告诉我这是怎么做到的吗?或者也许有人可以向我解释过滤器的概念?

【问题讨论】:

    标签: java spring spring-boot oauth


    【解决方案1】:

    这对我有用。在同一个类中再次配置@Override,像这样:

    @Override
    public void configure(WebSecurity web) throws Exception {
        web.ignoring().antMatchers('/languages/**');
    }
    

    对于 /languages 下的任何端点,应该不再需要 OAUTH

    【讨论】:

      猜你喜欢
      • 2018-10-28
      • 2018-04-25
      • 2011-08-09
      • 1970-01-01
      • 2015-07-23
      • 1970-01-01
      • 2021-09-05
      • 2021-10-01
      • 2016-05-25
      相关资源
      最近更新 更多