I have an ASP.NET Core 6.0 web API which is currently deployed in an on-premise environment.
I am trying to protect the API with OAUTH 2.0 client credential flow using Azure AD as authentication server.
The clients that will be calling the API are external partners server (daemon) applications. There will be multiple clients, but each client will develop their own service to connect with my API. The requirement is to be able to set an authorization rule which would allow a specific partner to only send the data for its own resources. For instance - client A can only send documents for partners which are related to client A.
What I am struggling with is the right way to register client/clients in Azure AD. Should I:
- register only one client app and add a credential (cert/secret) for each specific partner? In that case - what's the appropriate way to identify clients at API level - if only one ClientId is registered?
- register multiple client apps - a new client app registration would be registered for each implementation. In that case - are there any availible resources that would help me to create a registration site which an external developer could use to self-register the client?
And another related question - what's the recommended way of getting authenticated ClientId of the caller in a client credential flow protected ASP.NET Core 6.0 web API controller? Right now i am checking the azp claim of access token. Is there a better way to identify the client that is calling the API?