Steps For Azure AD Integration in ASP
Steps For Azure AD Integration in ASP
using Microsoft.Identity.Web;
using Microsoft.AspNetCore.Authentication.JwtBearer;
builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationSche
me).AddMicrosoftIdentityWebApi(builder.Configuration, “AzureAd”);
We can skip the second argurment as we are using the AzureAd default.
7. After app.useHttpsRedirection() and before app.UseAuthorization() add
app.UseAuthentication();
9. We need to then define the scope to the controller function by using the
data annotation as shown below:
[RequiredScope("Forecast.Read")]
[HttpGet]
public IEnumerable<WeatherForecast> Get()
{
if we skip any endpoint with the above annotations then we will get forbidden error.
We can also add the above annotations at the controller level.