春季OAuth2安全问题

时间:2020-03-21 03:58:22

标签: spring spring-security-oauth2

我目前正在实现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(查询参数)中公开用户凭据可能会被各种网络嗅探工具捕获。

有没有办法用其他方法做到这一点?

1 个答案:

答案 0 :(得分:0)

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