Skip to content

Commit 07f0904

Browse files
committed
B2C sample preconfigured to Fabrikam
1 parent 654d45a commit 07f0904

File tree

6 files changed

+33
-32
lines changed

6 files changed

+33
-32
lines changed

1-WebApp-OIDC/1-5-B2C/Properties/launchSettings.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
"windowsAuthentication": false,
44
"anonymousAuthentication": true,
55
"iisExpress": {
6-
"applicationUrl": "http://localhost:3110/",
7-
"sslPort": 44321
6+
"applicationUrl": "https://localhost:44316/",
7+
"sslPort": 44316
88
}
99
},
1010
"profiles": {
@@ -21,7 +21,7 @@
2121
"environmentVariables": {
2222
"ASPNETCORE_ENVIRONMENT": "Development"
2323
},
24-
"applicationUrl": "http://localhost:3110/"
24+
"applicationUrl": "https://localhost:44316/"
2525
}
2626
}
2727
}

1-WebApp-OIDC/1-5-B2C/README.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@ Navigate to the `"1-5-B2C"` folder
3838
cd "1-5-B2C"
3939
```
4040

41+
## Option 1 - Run the pre-configured sample
42+
43+
1. Build the solution and run it.
44+
1. Open your web browser and make a request to the app. Accept the IIS Express SSL certificate if needed. Click on **SignIn/Up** button.
45+
1. Click on Sign-In
46+
47+
## Option 2 - Configure the sample with your own B2C app
48+
4149
### Step 2: Get your own Azure AD B2C tenant
4250

4351
If you don't have an Azure AD B2C tenant yet, you'll need to create an Azure AD B2C tenant by following the [Tutorial: Create an Azure Active Directory B2C tenant](https://azure.microsoft.com/documentation/articles/active-directory-b2c-get-started).
@@ -57,7 +65,7 @@ Now you need to [register your web app in your B2C tenant](https://docs.microsof
5765
Your web application registration should include the following information:
5866

5967
- Enable the **Web App/Web API** setting for your application.
60-
- Set the **Reply URL** to `https://localhost:44321/signin/B2C_1_sign_up_in` and `https://localhost:44321/signout/B2C_1_sign_up_in`.
68+
- Set the **Reply URL** to `https://localhost:44136/signin/B2C_1_sign_up_in` and `https://localhost:44136/signout/B2C_1_sign_up_in`.
6169
- Copy the Application ID generated for your application, so you can use it in the next step.
6270

6371
### Step 5: Configure the sample with your app coordinates
@@ -82,7 +90,7 @@ Your web application registration should include the following information:
8290
}
8391
```
8492

85-
### Step 5: Run the sample
93+
### Step 6: Run the sample
8694

8795
1. Build the solution and run it.
8896
1. Open your web browser and make a request to the app. Accept the IIS Express SSL certificate if needed. Click on **SignIn/Up** button.
@@ -100,6 +108,9 @@ If your web site needs to be accessed from users using iOS 12, you probably want
100108
101109
## About The code
102110

111+
#### Where is MSAL?
112+
This sample does NOT use MSAL - it uses the built-in ASP.NET Core middlerware. MSAL is used for fetching access for accessing protected APIs (not shown here), as well as ID tokens. For logging-in purposes, it is sufficient to obtain an ID Token, and the middlerware is capable of doing this on its own.
113+
103114
The `AccountController.cs` used in this sample is part of the built-in .NET Core authentication controllers found in the NuGet package `Microsoft.AspNetCore.Authentication.AzureADB2C.UI`, and you can find its implementation [here](https://github.com/aspnet/AspNetCore/blob/master/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/Areas/AzureADB2C/Controllers/AccountController.cs). If you want to customize the **Sign-in**, **Sign-up** or **Sign-out** actions, you are encouraged to create your own controller.
104115

105116
This sample shows how to use the OpenID Connect ASP.NET Core middleware to sign in users from a single Azure AD B2C tenant. The middleware is initialized in the `Startup.cs` file by passing the default authentication scheme and `AzureADB2COptions.cs` options. The options are read from the `appsettings.json` file. The middleware takes care of:

1-WebApp-OIDC/1-5-B2C/Startup.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
3030
using Microsoft.AspNetCore.Mvc;
3131
using Microsoft.Extensions.Configuration;
3232
using Microsoft.Extensions.DependencyInjection;
33-
using Microsoft.Identity.Web;
3433

3534
namespace WebApp_OpenIDConnect_DotNet
3635
{

1-WebApp-OIDC/1-5-B2C/WebApp-OpenIDConnect-DotNet.csproj

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,4 @@
2323
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.3" />
2424
</ItemGroup>
2525

26-
<ItemGroup>
27-
<ProjectReference Include="..\..\Microsoft.Identity.Web\Microsoft.Identity.Web.csproj" />
28-
</ItemGroup>
29-
3026
</Project>

1-WebApp-OIDC/1-5-B2C/WebApp-OpenIDConnect-DotNet.sln

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio 15
4-
VisualStudioVersion = 15.0.27130.2027
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.29123.89
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WebApp-OpenIDConnect-DotNet", "WebApp-OpenIDConnect-DotNet.csproj", "{8DCFEEC2-0A85-4C7E-B96A-21C9184470B1}"
77
EndProject
8-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Identity.Web", "..\..\Microsoft.Identity.Web\Microsoft.Identity.Web.csproj", "{E0CEF26A-6CE6-4505-851B-6580D5564752}"
9-
EndProject
108
Global
119
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1210
Debug|Any CPU = Debug|Any CPU
@@ -17,10 +15,6 @@ Global
1715
{8DCFEEC2-0A85-4C7E-B96A-21C9184470B1}.Debug|Any CPU.Build.0 = Debug|Any CPU
1816
{8DCFEEC2-0A85-4C7E-B96A-21C9184470B1}.Release|Any CPU.ActiveCfg = Release|Any CPU
1917
{8DCFEEC2-0A85-4C7E-B96A-21C9184470B1}.Release|Any CPU.Build.0 = Release|Any CPU
20-
{E0CEF26A-6CE6-4505-851B-6580D5564752}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21-
{E0CEF26A-6CE6-4505-851B-6580D5564752}.Debug|Any CPU.Build.0 = Debug|Any CPU
22-
{E0CEF26A-6CE6-4505-851B-6580D5564752}.Release|Any CPU.ActiveCfg = Release|Any CPU
23-
{E0CEF26A-6CE6-4505-851B-6580D5564752}.Release|Any CPU.Build.0 = Release|Any CPU
2418
EndGlobalSection
2519
GlobalSection(SolutionProperties) = preSolution
2620
HideSolutionNode = FALSE
Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
{
2-
"AzureAdB2C": {
3-
"Instance": "https://<your-tenant-name>.b2clogin.com",
4-
"ClientId": "<web-app-application-id>",
5-
"Domain": "<your-b2c-domain>",
6-
"CallbackPath": "/signin/B2C_1_sign_up_in",
7-
"SignedOutCallbackPath": "/signout/B2C_1_sign_up_in",
8-
"SignUpSignInPolicyId": "<your-sign-up-in-policy>"
9-
},
10-
"Logging": {
11-
"LogLevel": {
12-
"Default": "Warning"
13-
}
14-
},
15-
"AllowedHosts": "*"
2+
"AzureAdB2C": {
3+
"Instance": "https://fabrikamb2c.b2clogin.com",
4+
"ClientId": "90c0fe63-bcf2-44d5-8fb7-b8bbc0b29dc6",
5+
"Domain": "fabrikamb2c.onmicrosoft.com",
6+
"SignedOutCallbackPath": "/signout/B2C_1_susi",
7+
"SignUpSignInPolicyId": "B2C_1_susi",
8+
//"CallbackPath": "/signin/B2C_1_sign_up_in" // defaults to /signin-oidc
9+
10+
},
11+
"Logging": {
12+
"LogLevel": {
13+
"Default": "Warning"
14+
}
15+
},
16+
"AllowedHosts": "*"
1617
}

0 commit comments

Comments
 (0)