We got the following situation:
External Network
- 1 some application we don't control
Internal Network:
- 1 internal api (azure function)
- Active Directory B2C
I want to secure my internal api according to the official microsoft documentation (first bullet point). But to accomplish this we would need to authenticate the client with active directory.
Since the client calling our api is another application (not a user) we'd need to use the client credentials flow according to OAuth2. The Identity Provider then has to provide me a token containing a custom scope (that the other party can check)
Unfortunatelly after reading a bunch of documentation about how to use the Azure AD I'm not able to retrieve a JWT token that contains a custom scope.
I already tried to register an application in the active directory blade:
On its settings page i tried to register permissions (which seems to be the scopes in the world of AD) but it only shows the official microsoft apis.
How can i add permissions for an external api?
The token created with the app key also does not contain a "scp" or "scope" claim. How can i get scope claim into the token?
Update 1
I registered an application in the AD B2C Blade for my api (our-api):
For the clients I registered applications in the AD Blade (TestClient 1 and TestClient 2):
TestClient 1 requires permission to my "our-api" application:
TestClient 2 doesn't require any permission:
When I try to login to AD with the TestClient 1 I get an access_token as expected. But if I try to login as TestClient 2 I get an access_token as well. Shouldn't this process fail? How can i verify that only TestClient 1 has the permission?