Binding scopes with user roles to protect user's resources
By using scopes we can add fine-grained protection to the user's resources. Spring Security also provides the concept of roles which can be interchangeable with scopes defined by Spring Security OAuth2. As explained by Dave Syer (leader of the Spring Securit OAuth2 project), roles and scopes are just arbitrary strings that might be considered as the same thing (you can read more about this explanation at https://stackoverflow.com/questions/22417780/using-scopes-as-roles-in-spring-security-oauth2-provider). This recipe presents you with how to bind scopes that are available for some client details with the roles that a Resource Owner might have. In this case, the Resource Owner would be able to approve scopes that are related to her roles.
Getting ready
To run this recipe, you will need Java 8, Maven, Spring Web, and Spring security. To ease the project creation step, use Spring Initializr at http://start.spring.io/ and define the dependencies...