Skip to content

Commit 0eaaf9f

Browse files
author
Tiago Brenck
authored
Merge pull request #338 from Azure-Samples/tibre/webUiDocs
Microsoft.Identity.Web.UI optional steps
2 parents fc1c2d9 + d5cd4f9 commit 0eaaf9f

File tree

4 files changed

+85
-1
lines changed

4 files changed

+85
-1
lines changed

1-WebApp-OIDC/1-1-MyOrg/README.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,13 +172,34 @@ cd "1-WebApp-OIDC\1-1-MyOrg"
172172
- update the `sslPort` of the `iisSettings` section to be `44321`
173173
- in the `applicationUrl` property of use `https://localhost:44321`
174174
175+
1. (Optional) If you don't have a custom `AccountController` to handle the *sign-in* and *sign-out* requests, you can use the `Microsoft.Identity.Web.UI` built-in one. For that, please include this change on **Startup.cs**:
176+
177+
- at the top of the file, add the following using directive:
178+
179+
```CSharp
180+
using Microsoft.Identity.Web.UI;
181+
```
182+
- in the `ConfigureServices` method, change the **AddControllersWithView** code snippet with this:
183+
184+
```CSharp
185+
services.AddControllersWithViews(options =>
186+
{
187+
var policy = new AuthorizationPolicyBuilder()
188+
.RequireAuthenticatedUser()
189+
.Build();
190+
options.Filters.Add(new AuthorizeFilter(policy));
191+
}).AddMicrosoftIdentityUI();
192+
```
193+
194+
- on **Views/Shared/_LoginPartial.cshtml**, change the **asp-area** tag to: `asp-area="MicrosoftIdentity"`
195+
175196
### Step 3: Run the sample
176197

177198
1. Build the solution and run it.
178199

179200
2. Open your web browser and make a request to the app. Accept the IIS Express SSL certificate if needed. The app immediately attempts to authenticate you via the identity platform endpoint. Sign in with your personal account or with work or school account.
180201

181-
## Toubleshooting
202+
## Troubleshooting
182203

183204
### known issue on iOS 12
184205

1-WebApp-OIDC/1-2-AnyOrg/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,27 @@ cd "1-WebApp-OIDC\1-2-AnyOrg"
164164
- update the `sslPort` of the `iisSettings` section to be `44321`
165165
- in the `applicationUrl` property of use `https://localhost:44321`
166166
167+
1. (Optional) If you don't have a custom `AccountController` to handle the *sign-in* and *sign-out* requests, you can use the `Microsoft.Identity.Web.UI` built-in one. For that, please include this change on **Startup.cs**:
168+
169+
- at the top of the file, add the following using directive:
170+
171+
```CSharp
172+
using Microsoft.Identity.Web.UI;
173+
```
174+
- in the `ConfigureServices` method, change the **AddControllersWithView** code snippet with this:
175+
176+
```CSharp
177+
services.AddControllersWithViews(options =>
178+
{
179+
var policy = new AuthorizationPolicyBuilder()
180+
.RequireAuthenticatedUser()
181+
.Build();
182+
options.Filters.Add(new AuthorizeFilter(policy));
183+
}).AddMicrosoftIdentityUI();
184+
```
185+
186+
- on **Views/Shared/_LoginPartial.cshtml**, change the **asp-area** tag to: `asp-area="MicrosoftIdentity"`
187+
167188
### Step 3: Run the sample
168189

169190
1. Build the solution and run it.

1-WebApp-OIDC/1-3-AnyOrgOrPersonal/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,27 @@ In the **appsettings.json** file:
159159
- update the `sslPort` of the `iisSettings` section to be `44321`
160160
- in the `applicationUrl` property of use `https://localhost:44321`
161161
162+
1. (Optional) If you don't have a custom `AccountController` to handle the *sign-in* and *sign-out* requests, you can use the `Microsoft.Identity.Web.UI` built-in one. For that, please include this change on **Startup.cs**:
163+
164+
- at the top of the file, add the following using directive:
165+
166+
```CSharp
167+
using Microsoft.Identity.Web.UI;
168+
```
169+
- in the `ConfigureServices` method, change the **AddControllersWithView** code snippet with this:
170+
171+
```CSharp
172+
services.AddControllersWithViews(options =>
173+
{
174+
var policy = new AuthorizationPolicyBuilder()
175+
.RequireAuthenticatedUser()
176+
.Build();
177+
options.Filters.Add(new AuthorizeFilter(policy));
178+
}).AddMicrosoftIdentityUI();
179+
```
180+
181+
- on **Views/Shared/_LoginPartial.cshtml**, change the **asp-area** tag to: `asp-area="MicrosoftIdentity"`
182+
162183
### Step 3: Run the sample
163184

164185
1. Build the solution and run it.

1-WebApp-OIDC/1-4-Sovereign/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,27 @@ cd "1-WebApp-OIDC\1-4-Sovereign"
130130
- update the `sslPort` of the `iisSettings` section to be `44321`
131131
- in the `applicationUrl` property of use `https://localhost:44321`
132132
133+
1. (Optional) If you don't have a custom `AccountController` to handle the *sign-in* and *sign-out* requests, you can use the `Microsoft.Identity.Web.UI` built-in one. For that, please include this change on **Startup.cs**:
134+
135+
- at the top of the file, add the following using directive:
136+
137+
```CSharp
138+
using Microsoft.Identity.Web.UI;
139+
```
140+
- in the `ConfigureServices` method, change the **AddControllersWithView** code snippet with this:
141+
142+
```CSharp
143+
services.AddControllersWithViews(options =>
144+
{
145+
var policy = new AuthorizationPolicyBuilder()
146+
.RequireAuthenticatedUser()
147+
.Build();
148+
options.Filters.Add(new AuthorizeFilter(policy));
149+
}).AddMicrosoftIdentityUI();
150+
```
151+
152+
- on **Views/Shared/_LoginPartial.cshtml**, change the **asp-area** tag to: `asp-area="MicrosoftIdentity"`
153+
133154
### Step 3: Run the sample
134155

135156
1. Build the solution and run it.

0 commit comments

Comments
 (0)