I am overseeing operations and development for an internal system at a company using Windows Server 2022. Until now, this system did not have any authentication, and was accessible by anyone. I would like to implement Azure AD authentication using the Open ID Connect method.
However, none of the development team members have experience with Azure AD authentication, and we are unclear about how to proceed with its implementation. Could anyone who is knowledgeable in this area provide some guidance?
In addition, if anyone has information on how to add Azure AD authentication to an existing web application hosted on IIS, that would be extremely helpful.
Our application configuration is as follows: Windows Server 2022 + IIS 10.0 + ASP.NET front-end: .NET Framework 4.8
Any assistance would be greatly appreciated. Thank you in advance.
You can follow these below steps to Implement Azure AD authentication using Open ID Connect in your existing ASP.NET application:
1)Register app in azure AD:
Client ID
andTenant ID
.2)Installl
Microsoft.IdentityModel.Protocols.OpenIdConnect
,Microsoft.AspNetCore.Authentication.AzureAD.UI
, andMicrosoft.AspNetCore.Authentication
nuget packages3)Startup.cs:
In the
Configure
method ofStartup.cs
, ensure you haveapp.UseAuthentication();
beforeapp.UseMvc();
4)appsettings.json:
5)Add
[Authorize]
attribute to the controllers or actions you want to secure.6)Configure the
web.config
file in your ASP.NET application to use the Azure AD authentication settings, such as the Client ID and Tenant ID.