title: spring boot OAuth2 role based authorization
body: <p>We have a dedicated authorization server extending AuthorizationServerConfigurerAdapter, where we have set authorities overriding void configure(ClientDetailsServiceConfigurer clients) method.</p>
  
  <pre><code>    @Configuration
      @EnableAuthorizationServer
      protected static class OAuth2Config extends AuthorizationServerConfigurerAdapter {
  
      @Value('${oauth.clientId}')
      private String clientId
  
      @Value('${oauth.secret:}')
      private String secret
  
      @Value('${oauth.resourceId}')
      private String resourceId
  
      @Autowired
      @Qualifier('authenticationManagerBean')
      private AuthenticationManager authenticationManager
  
      @Bean
      public JwtAccessTokenConverter accessTokenConverter() {
          return new JwtAccessTokenConverter();
      }
  
      @Override
      public void configure(AuthorizationServerSecurityConfigurer oauthServer) throws Exception {
          oauthServer.checkTokenAccess("permitAll()")
          oauthServer.allowFormAuthenticationForClients()
      }
  
      @Override
      public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception {
          endpoints.authenticationManager(authenticationManager)
                  .accessTokenConverter(accessTokenConverter())
      }
  
      @Override
      public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
          clients.inMemory()
                  .withClient(clientId)
                  .secret(secret)
                  .authorizedGrantTypes("password", "authorization_code", "refresh_token", "implicit")
                  .authorities("USER", "ADMIN")
                  .scopes("read", "write", "trust")
                  .resourceIds(resourceId)
      }
  </code></pre>
  
  <p>Now how to use the authorities in the resource server for role based authorization.
  We are able to authenticate via authorization server generated token.
  Need help.</p>