# Authorization Extension - Roles - Problem

**URL:** <https://community.auth0.com/t/authorization-extension-roles-problem/7575>\
**Category:** Get Help\
**Tags:** extensions, java, spring-security, spring-boot\
**Created:** [July 19, 2017, 5:17am UTC](https://community.auth0.com/t/authorization-extension-roles-problem/7575 "2017-07-19T05:17:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lisandro\_Rezoagli](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@Lisandro\_Rezoagli](https://community.auth0.com/u/Lisandro_Rezoagli)\
**Post date:** [July 19, 2017, 5:17am UTC](https://community.auth0.com/t/authorization-extension-roles-problem/7575/1 "2017-07-19T05:17:46Z")

</div>

I describe the case.

All users are users of google.

In my frontend, I’m using angular-auth0.  
Example:

```
   angularAuth0Provider.init({
        clientID:AUTH0_CLIENT_ID,
        domain: .AUTH0_DOMAIN,
        responseType: 'token id_token',
        scope: 'openid profile',
        redirectUri: REDIRECT,
        audience: 'https://example-api.com'
    });

```

Backend: auth0-spring-security-api

```
JwtWebSecurityConfigurer
            .forRS256(audience, domain)
            .configure(http)
            .authorizeRequests()
            .antMatchers("/ping", "/pong", "/version").permitAll()
            .antMatchers("/api/v1/bye/**").permitAll()
            .antMatchers("/api/v1/hello/**").authenticated()

```

To my backend, several different Clients access, some one single page, others non-interactive through the API.

To users of the one simple page, I need to create ROLES.  
I use “Authorization Extension”

Add the rules,

```
function (user, context, callback) {
  var namespace = 'http://example.com/claims/'; 
  context.idToken[namespace + "permissions"] = user.permissions;
  context.idToken[namespace + "groups"] = user.groups;
  context.idToken[namespace + "roles"] = user.roles;
  
  context.accessToken[namespace + "permissions"] = user.permissions;
  context.accessToken[namespace + "groups"] = user.groups;
  context.accessToken[namespace + "roles"] = user.roles;
  
  callback(null, user, context);
}

```

The problem comes with configuring JwtWebSecurityConfigurer,

Try using,

```
 .antMatchers("/ping", "/pong", "/version").hasAuthority ("ROLE_USER")
 .antMatchers("/ping", "/pong", "/version").hasAnyRole ("ROLE_USER")
 .antMatchers("/ping", "/pong", "/version").hasRole ("ROLE_USER")

```

But none works, all return 403.

Any ideas?

---

<div class="post-metadata">

**Author:** ![jmangelo](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jmangelo/32/7923_2.png) [@jmangelo](https://community.auth0.com/u/jmangelo)\
**Post date:** [July 19, 2017, 3:20pm UTC](https://community.auth0.com/t/authorization-extension-roles-problem/7575/2 "2017-07-19T15:20:52Z")

</div>

Based on the discussion that happened in this GH [issue](https://github.com/auth0/auth0-spring-security-api/issues/23) reported in the associated library repository the **authorities are obtained only by looking at the `scope` claim of the received access token**.

The above implies that although you’re including roles information in the access token, you’re doing so through the means of a custom claim `http://example.com/claims/roles` while the library will only read authority information from the `scope` claim. The mismatch in the claim name will then cause any use of `hasAuthority` to result in a 403 because the authority was not available.

One possible alternative would be the rule performing a transformation from roles to scopes and set them as appropriate so that the library will then read them and in this way allowing the use of `hasAuthority`.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [March 2, 2018, 5:55am UTC](https://community.auth0.com/t/authorization-extension-roles-problem/7575/3 "2018-03-02T05:55:28Z")

</div>


