【问题标题】:OAuthToken.authorities are not filled in spring security oauth facebook plugin in Grails 2.3Grails 2.3中的spring security oauth facebook插件未填写OAuthToken.authorities
【发布时间】:2014-07-02 11:15:26
【问题描述】:

我正在使用

  compile ':spring-security-core:2.0-RC2'
  compile ':spring-security-oauth:2.0.2'
  compile ':spring-security-oauth-facebook:0.1'

在我的项目中。

在脚手架 SpringSecurityOAuthController 中有一个更新 OAuthToken 的方法:

protected OAuthToken updateOAuthToken( OAuthToken oAuthToken, UserAccount user ) {
  //....
  oAuthToken.principal = user
  oAuthToken.authorities = user.authorities // Set<GrantedAuthorities>
  oAuthToken.authenticated = true

  oAuthToken
}

当我登录时,我没有看到权限设置:

grails.plugin.springsecurity.oauth.FacebookOAuthToken@a3795c4b: 校长: ;凭证:[受保护];已认证:真实;详细信息:空;未授予任何权限

虽然用户的角色是ROLE_USER, ROLE_ADMIN

我检查了类结构,发现:

class FacebookOAuthToken extends OAuthToken {..}

和

abstract class OAuthToken extends AbstractAuthenticationToken {
    ///....
    Collection<GrantedAuthority> authorities
}

和

public abstract class AbstractAuthenticationToken implements Authentication, CredentialsContainer {
  //...
  private final Collection<GrantedAuthority> authorities;
}

因此,权限显然来自 AbstractAuthenticationToken.authorities 属性,而不是来自 OAuthToken.authorities。

有机会解决这个问题吗?

【问题讨论】:

    标签: grails spring-security oauth-2.0 facebook-oauth


    【解决方案1】:

    好的,问题出在其他地方:)

    我应该使用&lt;sec:ifAnyGranted&gt; 而不是&lt;sec:ifAllGranted&gt; 来检查当局...

    【讨论】:

      猜你喜欢
      • 2015-02-12
      • 2012-08-06
      • 2014-03-07
      • 2012-01-24
      • 2017-09-16
      • 2016-05-24
      • 2013-01-17
      • 2011-08-15
      • 2016-03-23
      相关资源
      最近更新 更多