当使用Spring Security Rest Plugin时,从GitHub接收到废弃警告。

问题描述 投票:0回答:1

我有一个Grails 3应用程序,使用spring-security-rest插件2.0.0.RC1版本,使用GitHub进行用户认证。

我看到GitHub发出警告。

Your application used an access token as part of a query parameter to access an endpoint through the GitHub API:
    https://api.github.com/user
Please use the Authorization HTTP header instead as using the `access_token` query parameter is deprecated.

是否有一个版本已经修复了这个问题,仍然可以在Grails 3中使用?

我相信在2020年11月,废弃警告就会变成失败。

更新。 在pac4j中,我看到OAuthConfiguration类中有一个tokenAsHeader变量。如果设置了,它就会在获取用户信息时将授权令牌添加到头中。

我不确定这样做是否有效,但我在application.groovy中添加了tokenAsHeader = true。

github {
  client = org.pac4j.oauth.client.GitHubClient 
  key = '${APP_KEY}' 
  secret = '${APP_SECRET}' 
  scope = 'user' 
  tokenAsHeader = true
  defaultRoles = ['ROLE_GITHUB'] 
}

我在调试输出中没有看到任何变化,而且我只定期收到废弃警告邮件,所以我不确定这是否是一个解决方案。

grails spring-security-rest
1个回答
0
投票

如你所想,OAuth客户端不是Spring Security REST本身的一部分,而是来自Pac4j。Spring Security REST 2.0.0.0.RC1与Pac4j 2.2.1一起发布,Pac4j 2.2.1是2.5年前的版本。所以,有可能当时对客户端的有效设置,现在已经被废弃了。

你的机会是

  1. 在本地升级到一个新的Pac4j版本。一直升级到4.0.0,应该可以顺利升级,在。build.gradle:

    compile("org.grails.plugins:spring-security-rest:2.0.0.RC1") {
        exclude group: 'org.pac4j'
    }
    compile "org.pac4j:pac4j-core:3.8.3"
    compile "org.pac4j:pac4j-oauth:3.8.3"
    
  2. 将您的应用程序升级到Grails 4,并使用Spring Security REST 3.0.1,它使用pac4j 3.8.3。

© www.soinside.com 2019 - 2024. All rights reserved.