【问题标题】:Spring OAuth2 security concernsSpring OAuth2 安全问题
【发布时间】:2020-07-02 04:35:52
【问题描述】:

我目前正在实施 Authorization_Code 类型的 OAuth2 流程,以便在我的网站上进行单点登录 (SSO)。

这是我启用它的代码。

  @Override
  protected void configure(final HttpSecurity http) throws Exception {
    // @formatter:off
    http.authorizeRequests()
        .antMatchers("/login", "/authorize", "/error")
        .permitAll()
        .anyRequest()
        .authenticated()
        .and().formLogin().loginPage("https://sso.mywebsite.com").loginProcessingUrl("/perform_login")
        .defaultSuccessUrl("/success",true)
        .failureUrl("/error").permitAll()
        .and()
        .csrf()
        .disable();
    // @formatter:on
  }

我的担忧如下所述。

要发出登录请求(使用用户名和密码),sso.mywebsite.com 应该向我的 oAuth 服务 - http://oauth/perform_login?username=USERNAME&password=PASSWORD 发出 POST 请求。

我用 Postman 试了一下,效果很好。但是,在查询参数中发送像上面这样的普通用户名和密码不是一个安全问题吗?我认为在 uri(查询参数)中暴露用户凭据可能会被各种网络嗅探工具捕获。

有没有办法用不同的方法做到这一点?

【问题讨论】:

    标签: spring spring-security-oauth2


    【解决方案1】:
    1. 只要您使用 HTTPS,您的查询参数就是安全的。
    2. 我不清楚,为什么您的 SSO 网站应该对那个 URL 进行 POST(还有,为什么不使用 POST 正文,而是通过 url 附加参数)。它不应该“重定向”到登录页面/授权服务器还是上面的代码来自您的授权服务器?根据您的描述,有点不清楚。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-11-26
      • 2017-08-06
      • 2016-08-20
      • 2012-06-15
      • 1970-01-01
      • 2017-08-28
      • 2011-09-26
      • 2016-08-23
      相关资源
      最近更新 更多