Let\'s consider a fairly simple hypothetical application where users can read or write posts.
Some users can read and write articles while some others can only read
Scopes (and roles) are arbitrary strings, so there is no problem if you want to make then the same. To make the access rule declarations identical you could write an ExpressionHandler
that tested authorities or scopes with the same values depending on the type of Authentication
it found.
A different approach suggests itself after you read the comments: add a custom TokenStore
or ResourceServerTokenServices
. These are easily accessible extension points and would permit modifying the OAuth2Authentication
so that its granted authorities were the same as the scopes.
My preference, however, is to control the allowed scopes using a OAuth2RequestFactory
, limiting them at the point of the token grant to values that are consistent with the user's authorities.