This is a sample app featuring the Azure Active Directory authentication sample for DotVVM.
-
Sign in to the Azure Portal and open (or create) your Azure Active Directory resource.
-
Open the Overview tab and copy the Directory ID value. Paste it in the
TenantIdapplication setting in theweb.configfile in OWIN orappsettings.jsonin ASP.NET Core. -
Open the App registrations tab and open (or create) the app registration.
-
Copy the Application ID value and paste it in the
ClientIdapplication setting in theweb.configorappsettings.jsonfile. -
Make sure that the URL on which the web app is running, is listed in the Home Page field or in the Reply URLs section. The URL must match including the HTTP/HTTPS and port.
-
In ASP.NET Core version, set the
PostLogoutRedirectUriapplication setting to the application root URL.
Now the application should work with all accounts from the directory.
Note: If you decide to use code response type instead of default id_token, generate and set ClientSecret in the configuration file as well. The secret can be generated in App registrations page in the Authentication section.
If you want to make the application multi-tenant (to allow the users to sign in even if they are from a different Azure Active Directory tenant), you need to make these changes:
-
In the Properties tab of the App Registration, switch the Multi-tenanted field to Yes.
-
In the
web.configorappsettings.json, change theTenantIdto the valuecommon.
-
Open the GitHub repo in Visual Studio or
git clone https://github.com/riganti/dotvvm-samples-dotvvm-samples-azuread-auth.git -
Open
AspNetCore/DotvvmAuthSample/DotvvmAuthSample.sln(ASP.NET Core) orOwin/DotvvmAuthSample/DotvvmAuthSample.sln(.NET Framework with OWIN) -
Right-click the
DotvvmAuthSampleproject and select View > View in Browser
- How to configure Azure Active Directory authentication in a DotVVM application (see Authentication page in the DotVVM Docs to find more info)