Disclaimer: this will not be an exhaustive answer. This is not in my head.
OpenID Connect provides an authentication layer on top of OAuth. In your case, Active Directory provides authentication and sends back the access_token . An access token represents an authenticated AD user. If you are running OpenID Connect, then AD will also send an id_token , which may contain additional identification information (for example, birthday, avatar, and everything that AD issues).
Neither OpenID Connect nor Active Directory has anything to do with the roles that your application assigns to the user; roles are all you need. You assign user roles in the same way as usual; you assign them a nameid , but instead of an email address or username. Your application no longer needs to authenticate the user, but it needs to be assigned nameid roles.
How is the identifier of the calling API determined - is the identifier determined from the call on the client or on the server?
The identity is embedded in access_token , which AD includes in its response. This token will have a nameid in which your application can be associated with a user and role. nameid is similar to the email address, username or other unique identifier that your application uses to recognize the user.
How to restrict access to some API endpoints based on user role?
You choose. When your application receives a request with a specific access_token , this token will be associated with a specific user through its nameid , and you can assign all roles and rights to that user. Basically, associate roles with nameid .
What can I do to achieve this based on existing middleware and libraries available to me?
There is an incomplete demo here , although it does not use Active Directory as a provider, instead it uses an internal provider. For demonstration, the username is shaun and the password is Testing123! . The source code is here .
Here is a link to the source of another demo , but again, it does not use Active Directory as a provider, but instead uses Twitter.
The best part about OAuth and OpenID Connect is that we can use any identity provider we want, so you can adapt the demos to use Active Directory.