grails / grails-spring-security-rest

Grails plugin to implement token-based, RESTful authentication using Spring Security
http://alvarosanchez.github.io/grails-spring-security-rest/
Other
203 stars 117 forks source link

Error getStringArrayClaim #182

Closed vbarrier closed 9 years ago

vbarrier commented 9 years ago

In 1.5.0M2 there is an error :

def roles = jwt.JWTClaimsSet.getStringArrayClaim('roles')?.collect { new SimpleGrantedAuthority(it) }

should be

def roles = jwt.JWTClaimsSet.getCustomClaim('roles')?.collect { new SimpleGrantedAuthority(it) }
alvarosanchez commented 9 years ago

@vbarrier why do you think it is an error? As far as I know, the getXXXClaim methods just return them in XXX format. I'm requesting them in an array format (I could have used getStringListClaim() as well) because is the way I generate them on the first place, as per this line:

claimsSet.setCustomClaim('roles', details.authorities?.collect { it.authority })

roles in JSON format will always be like ["ROLE_A", "ROLE_B"]

vbarrier commented 9 years ago

With getStringArrayClaim I get an error:

2015-03-26 18:24:06,604 [http-nio-8080-exec-6] ERROR [/prember].[default]  - Servlet.service() for servlet [default] in context with path [/prember] threw exception
Message: No signature of method: com.nimbusds.jwt.JWTClaimsSet.getStringArrayClaim() is applicable for argument types: (java.lang.String) values: [roles]
Possible solutions: getStringClaim(java.lang.String)
    Line | Method
->>   55 | loadUserByToken in com.odobo.grails.plugin.springsecurity.rest.token.storage.jwt.JwtTokenStorageService
vbarrier commented 9 years ago

Okey... I found why I had an error on this.

I had a plugin with :

   compile 'com.nimbusds:nimbus-jose-jwt:3.1.1'

I removed that dependency and know it works with StringArrayClaim :)