title: How to protect spring-security-oauth resources using @PreAuthorize based on Scope?
body: <p>I successfully configured spring-security-oauth2 so that external apps can authenticate with my application. However based on the external app and based on what the user allows, only a subset of my API should be accessible to clients. The available subset is determined by the OAuth Scopes.</p>
  
  <p>In classic Spring applications I could use @PreAuthorize to enforce boundaries based on roles:</p>
  
  <pre class="lang-java prettyprint-override"><code>@Controller
  public class MyController {
    @PreAuthorize("hasRole('admin')")
    @RequestMapping("...")
    public String doStuff() {
      // ...
    }
  }
  </code></pre>
  
  <p>How do I do the same when using OAuth and with Scopes instead of roles?</p>