As a developer of OAuth2 client applications, I want to ask my users for specific consent to perform actions on their behalf when interacting with IDM.
For example, if a client application wants to monitor notifications for a user, then that application should only ask for the "fr:idm:notifications" scope. As a result, if this client app tries to make some non-notifications-related request (for example, to update the user's profile) then that request should be denied (even if that user would normally be allowed to make the request, if they were operating on their own behalf).
The logic associated with checking scopes included in the access token should be done in addition to whatever additional authorization logic is normally evaluated for the subject of the access token. There is no reason that a client acting on a user's behalf should have any wider authorization than the user themselves would have.
As a proof of concept implementation of this scope checking mechanism, here is some configuration that can be referred to:
The main block added here for this PoC is the first item in the "filters" array within router.json. This calls to a script which uses the declaration of request/scope patterns to verify that the required scope for the request is present. Any request which does not include the required scope should fail.