Protecting an ASP.NET Core API with Microsoft Entra ID: JWT Validation and Scope Policies
A developer built entra-id-api-dotnet, a small ASP.NET Core 8 API that demonstrates JWT validation and separate scope and role authorization policies. The project requires a tenant ID and audience, builds the authority from the tenant, and validates issuer, audience, signature, and lifetime, accepting only RS256 tokens. Its 14 integration tests pass in GitHub Actions using locally signed tokens, though they do not connect to a live Microsoft Entra tenant. Authorization policies check the scp claim for api.read by splitting space-separated values and comparing them exactly, avoiding substring matches. The article emphasizes keeping authentication failures distinct from authorization failures in both implementation and HTTP responses.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in