4Manuals

  • PDF Cloud HOME

@ EnableOAuth2Sso和@EnableResourceServer(同一应用程序中的客户端和资源行为) Download

    春季启动-Couchbase AbstractCouchbaseConfiguration-如何避免覆盖不必要的方法 我不知道(未解决的编译问题:) 加载数据并推送到未显示的RecyclerView中 调用Model类的函数时出现java.lang.NullPointerException 字符串数组在for循环中初始化时忽略索引0 Spring MVC @ModelAttribute未填充AJAX发布请求 需要建议在Java中使用哪个数据库/存储来存储RaftLogs(实现Raft Consensus Algorithm) Flutter:Java使用或覆盖已弃用的API 中断可运行线程的问题 Spring Singleton更新集

我知道也有一些类似的话题,但是它们都是关于实现方面的困难,而我的问题是更明智的。 而且通常与springframework无关。

比方说,有一个应用程序可以实现两种客户端\资源(就OAuth2而言)行为。 它还支持出于测试目的的基本身份验证(它具有自己的一组static \ ldap用户)。 身份验证提供程序是作为单独的应用程序完成的。

通过

可以访问此“三类”身份验证
@Configuration
@Order(Ordered.HIGHEST_PRECEDENCE)
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {

@Override
    public void configure(HttpSecurity http) throws Exception {
        http
                .requestMatcher(request -> {
                    String auth = request.getHeader("Authorization");
                    return (auth != null && auth.startsWith("Basic"));
                })
                .authorizeRequests()
                .antMatchers("/", "/login**").permitAll()
                .anyRequest().authenticated()
                .and().csrf().disable()
                .httpBasic()
        ;
    }
    ....
}

然后去

@Configuration
@EnableResourceServer
public class OAuth2ResourceServerConfig extends ResourceServerConfigurerAdapter {
    private final static Logger logger = LoggerFactory.getLogger(OAuth2ResourceServerConfig.class);

    @Override
    public void configure(HttpSecurity http) throws Exception {
        http
                .requestMatcher(request -> {
                    String auth = request.getHeader("Authorization");
                    return (auth != null && auth.startsWith("Bearer"));
                })
                .authorizeRequests()
                .anyRequest().authenticated();
    }
    ....
}

然后

@Configuration
@EnableOAuth2Sso
@Order(4)
public class OAuth2SsoConfig extends WebSecurityConfigurerAdapter {

    @Override
    public void configure(HttpSecurity http) throws Exception {
        http.antMatcher("/**").authorizeRequests()
                .antMatchers("/", "/login**").permitAll()
                .anyRequest().authenticated()
                .and().csrf().disable()
        ;
    }
    ....
}
  • 全部包含在一个包中(连同UI)。

那很好。但。 拥有那样的功能真的很好吗? 此应用程序与之集成的某些系统本身已经具有“客户端”行为(例如SalesForce),因此UI和@ EnableOAuth2Sso配置似乎很沉重。

我是否在安全漏洞方面缺少某些东西?我能够看到,一旦应用程序接受了一个承载令牌,它将创建会话,邮递员会在下一个请求时将cookie发送回应用程序,并且即使将另一个承载令牌(用于另一个用户)应用到应用程序,应用程序也将管理该会话。授权标头。

通过maven配置文件或将其拆分为单独的应用程序(纯UI&client和Resource API)进行自定义是否有意义?

我看到的三个选项:

enter image description here

谢谢。

0 个答案:

没有答案



Similar searches
    占用空间分隔的输入时,SIGSEGV运行时错误 react-native-maps构建失败 @SuppressLint(“ CheckResult”)似乎不起作用 数据库中列出的产品未在管理>产品列表中列出 无法更新Python对象属性