You are designing an ASP.NET Core Web API that is called by a web-based front-end client application. The Web API needs to request data from a downstream reporting database service. To comply with data privacy policies, the requests to the downstream service must execute under the security context of the specific user who logged into the front-end application, allowing the reporting service to audit access by individual user accounts. Which authentication flow and client application type should you implement in the Web API to meet these requirements?
- AA system-assigned managed identity configured on the Web API host
- BThe client credentials flow using a confidential client application
- The OAuth 2.0 On-Behalf-Of flow using a confidential client applicationAnswer
- DThe authorization code flow using a public client application
Answer
The OAuth 2.0 On-Behalf-Of flow using a confidential client application
The OAuth 2.0 On-Behalf-Of flow is specifically designed for Web APIs that need to call downstream APIs while propagating the original user's identity and permissions. Because a Web API runs on a server and can protect credentials, it must be implemented as a confidential client application.
Step-by-Step Solution
Key Concept
OAuth 2.0 On-Behalf-Of flow for user context propagation in Web APIs