使用Spring Security Rest插件时收到来自GitHub的弃用警告



我有一个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月,这些贬低警告将成为失败。

更新:我在OAuthConfiguration类中看到pac4j周围有一个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'] 
}

我看不到调试输出有任何变化,我只定期收到不推荐使用的警告电子邮件,所以我不确定这是否是一个解决方案。

如您所知,OAuth客户端不是Spring Security REST本身的一部分,而是来自Pac4j。Spring Security REST 2.0.0.RC1附带有2.5年历史的Pac4j 2.2.1。因此,当时客户端的有效设置现在可能正在被弃用。

你的机会是:

  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

相关内容

最新更新