# Role with Spring security

**URL:** <https://community.auth0.com/t/role-with-spring-security/44824>\
**Category:** Get Help\
**Tags:** role, spring-security\
**Created:** [June 17, 2020, 10:47am UTC](https://community.auth0.com/t/role-with-spring-security/44824 "2020-06-17T10:47:36Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kmaeng](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/kmaeng/32/21999_2.png) [@kmaeng](https://community.auth0.com/u/kmaeng)\
**Post date:** [June 17, 2020, 10:47am UTC](https://community.auth0.com/t/role-with-spring-security/44824/1 "2020-06-17T10:47:36Z")

</div>

Hi, All.

I wanted to add “role” claim to access token but it’s not possible.  
I can use custom namespace with the role claim.  
So…how can I configure “hasRole” method in Spring Security if the token value is ‘[http://example.com/roles’=['admin](http://example.com/roles'=%5B'admin)’]?

```java
        http.authorizeRequests()
                .mvcMatchers("/public").permitAll()
                .mvcMatchers("/private").authenticated()
                .mvcMatchers("/private-scoped").hasAuthority("SCOPE_read:messages")
                .mvcMatchers("/private-role").hasRole("admin") //how can?
                .and()
                .oauth2ResourceServer().jwt();

```

Thanks!
