Skip to content

Commit febf801

Browse files
committed
Add an extra policy - edit profile
1 parent 07f0904 commit febf801

File tree

3 files changed

+23
-10
lines changed

3 files changed

+23
-10
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,10 @@ If your web site needs to be accessed from users using iOS 12, you probably want
111111
#### Where is MSAL?
112112
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.
113113

114+
#### Where is the Account controller?
114115
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.
115116

117+
#### B2C middlerware
116118
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:
117119

118120
- Requesting OpenID Connect sign-in using the policy from the `appsettings.json` file.
@@ -146,6 +148,10 @@ To understand more about Azure AD B2C see:
146148
- [Azure AD B2C documentation](https://docs.microsoft.com/en-us/azure/active-directory-b2c/)
147149
- [Azure AD B2C sign-in/sign-up user flow](https://docs.microsoft.com/en-us/azure/active-directory-b2c/active-directory-b2c-reference-policies)
148150

151+
To understand more about ASP.NET Core and Azure identity integration
152+
153+
- [ASP.NET Core Azure AD samples](https://github.com/aspnet/AspNetCore/tree/master/src/Azure/AzureAD/samples)
154+
149155
To understand more about token validation, see:
150156

151157
- [Validating tokens](https://github.com/AzureAD/azure-activedirectory-identitymodel-extensions-for-dotnet/wiki/ValidatingTokens)

1-WebApp-OIDC/1-5-B2C/Views/Shared/_LoginPartial.cshtml

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
11
@using System.Security.Principal
22
@if (User.Identity.IsAuthenticated)
33
{
4-
<ul class="nav navbar-nav navbar-right">
5-
<li class="navbar-text">Hello @User.Identity.Name</li>
6-
<li class="navbar-btn">
7-
<form method="get" asp-area="AzureADB2C" asp-controller="Account" asp-action="SignOut">
8-
<button type="submit" class="btn btn-primary">Sign Out</button>
9-
</form>
10-
</li>
11-
</ul>
4+
<ul class="nav navbar-nav navbar-right">
5+
<li class="navbar-text">Hello @User.Identity.Name</li>
6+
<!-- The Account controller is not defined in this project. Instead, it is part of Authentication.AzureADB2C.UI nuget pagacke and
7+
it defines some well known actions such as SignIn, SignOut and EditProfile-->
8+
<li class="navbar-btn">
9+
<form method="get" asp-area="AzureADB2C" asp-controller="Account" asp-action="EditProfile">
10+
<button type="submit" class="btn btn-primary" style="margin-right:5px">Edit Profile</button>
11+
</form>
12+
</li>
13+
<li class="navbar-btn">
14+
<form method="get" asp-area="AzureADB2C" asp-controller="Account" asp-action="SignOut">
15+
<button type="submit" class="btn btn-primary">Sign Out</button>
16+
</form>
17+
</li>
18+
</ul>
1219
}
1320
else
1421
{

1-WebApp-OIDC/1-5-B2C/appsettings.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
"ClientId": "90c0fe63-bcf2-44d5-8fb7-b8bbc0b29dc6",
55
"Domain": "fabrikamb2c.onmicrosoft.com",
66
"SignedOutCallbackPath": "/signout/B2C_1_susi",
7-
"SignUpSignInPolicyId": "B2C_1_susi",
7+
"SignUpSignInPolicyId": "b2c_1_susi",
8+
"EditProfilePolicyId": "b2c_1_edit_profile" // Optional profile editing policy
89
//"CallbackPath": "/signin/B2C_1_sign_up_in" // defaults to /signin-oidc
9-
1010
},
1111
"Logging": {
1212
"LogLevel": {

0 commit comments

Comments
 (0)