Trouble getting ClaimsPrincipal populated when using EasyAuth to authenticate against AAD on Azure App Service in a Asp.Net Core web app

后端 未结 5 2097
逝去的感伤
逝去的感伤 2020-11-29 09:13

We have a web app built on Asp.Net core. It doesn\'t contain any authentication middleware configured in it.

We are hosting on Azure App Service and using the Authen

5条回答
  •  失恋的感觉
    2020-11-29 09:31

    I wrote a small basic middleware to do this. It will create an identity based off of the .auth/me endpoint. The identity is created in the authentication pipeline so that [authorize] attributes and policies work with the identity.

    You can find it here:

    https://github.com/lpunderscore/azureappservice-authentication-middleware

    or on nuget:

    https://www.nuget.org/packages/AzureAppserviceAuthenticationMiddleware/

    Once added, just add this line to your startup:

    app.UseAzureAppServiceAuthentication();

提交回复
热议问题