Skip to content

Commit a067cca

Browse files
jmprieurjennyf19
andauthored
Jmprieur/relv2 (#667)
* testing for rel/v2 * Update to 2.0,4-preview * update to 2.0.6-preview * update to 2.0.7-preview * update to Microsoft.Identity.Web 2.0.8-preview * update to Microsoft.Identity.Web 2.0.8-preview * update to 2.5.0 * Improving the sample --------- Co-authored-by: Jennyf19 <[email protected]>
1 parent ca3427b commit a067cca

File tree

23 files changed

+74
-236
lines changed

23 files changed

+74
-236
lines changed

1-WebApp-OIDC/1-1-MyOrg/WebApp-OpenIDConnect-DotNet.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
<PrivateAssets>all</PrivateAssets>
2525
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2626
</PackageReference>
27-
<PackageReference Include="Microsoft.Identity.Web" Version="1.25.10" />
28-
<PackageReference Include="Microsoft.Identity.Web.UI" Version="1.25.10" />
27+
<PackageReference Include="Microsoft.Identity.Web" Version="2.5.0" />
28+
<PackageReference Include="Microsoft.Identity.Web.UI" Version="2.5.0" />
2929
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.0.0" />
3030
</ItemGroup>
3131

1-WebApp-OIDC/1-2-AnyOrg/WebApp-OpenIDConnect-DotNet.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
</ItemGroup>
1919

2020
<ItemGroup>
21-
<PackageReference Include="Microsoft.Identity.Web" Version="1.25.10" />
22-
<PackageReference Include="Microsoft.Identity.Web.UI" Version="1.25.10" />
21+
<PackageReference Include="Microsoft.Identity.Web" Version="2.5.0" />
22+
<PackageReference Include="Microsoft.Identity.Web.UI" Version="2.5.0" />
2323
</ItemGroup>
2424

2525
</Project>

1-WebApp-OIDC/1-3-AnyOrgOrPersonal/WebApp-OpenIDConnect-DotNet.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
</ItemGroup>
1919

2020
<ItemGroup>
21-
<PackageReference Include="Microsoft.Identity.Web" Version="1.25.10" />
22-
<PackageReference Include="Microsoft.Identity.Web.UI" Version="1.25.10" />
21+
<PackageReference Include="Microsoft.Identity.Web" Version="2.5.0" />
22+
<PackageReference Include="Microsoft.Identity.Web.UI" Version="2.5.0" />
2323
</ItemGroup>
2424

2525
</Project>

1-WebApp-OIDC/1-4-Sovereign/WebApp-OpenIDConnect-DotNet.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
</ItemGroup>
1919

2020
<ItemGroup>
21-
<PackageReference Include="Microsoft.Identity.Web" Version="1.25.10" />
22-
<PackageReference Include="Microsoft.Identity.Web.UI" Version="1.25.10" />
21+
<PackageReference Include="Microsoft.Identity.Web" Version="2.5.0" />
22+
<PackageReference Include="Microsoft.Identity.Web.UI" Version="2.5.0" />
2323
</ItemGroup>
2424

2525
</Project>

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
</ItemGroup>
1919

2020
<ItemGroup>
21-
<PackageReference Include="Microsoft.Identity.Web" Version="1.25.10" />
22-
<PackageReference Include="Microsoft.Identity.Web.UI" Version="1.25.10" />
21+
<PackageReference Include="Microsoft.Identity.Web" Version="2.5.0" />
22+
<PackageReference Include="Microsoft.Identity.Web.UI" Version="2.5.0" />
2323
</ItemGroup>
2424

2525
</Project>

2-WebApp-graph-user/2-1-Call-MSGraph/WebApp-OpenIDConnect-DotNet-graph.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
</PropertyGroup>
1010

1111
<ItemGroup>
12-
<PackageReference Include="Microsoft.Identity.Web.MicrosoftGraph" Version="1.25.10" />
13-
<PackageReference Include="Microsoft.Identity.Web.UI" Version="1.25.10" />
12+
<PackageReference Include="Microsoft.Identity.Web.MicrosoftGraph" Version="2.5.0" />
13+
<PackageReference Include="Microsoft.Identity.Web.UI" Version="2.5.0" />
1414
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.5" />
1515
</ItemGroup>
1616

2-WebApp-graph-user/2-2-TokenCache/WebApp-OpenIDConnect-DotNet.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.8" />
2222
<PackageReference Include="Microsoft.Extensions.Caching.SqlServer" Version="3.1.8" />
2323
<PackageReference Include="Microsoft.Extensions.Caching.StackExchangeRedis" Version="7.0.0" />
24-
<PackageReference Include="Microsoft.Identity.Web.UI" Version="1.25.10" />
25-
<PackageReference Include="Microsoft.Identity.Web.MicrosoftGraph" Version="1.25.10" />
24+
<PackageReference Include="Microsoft.Identity.Web.UI" Version="2.5.0" />
25+
<PackageReference Include="Microsoft.Identity.Web.MicrosoftGraph" Version="2.5.0" />
2626
</ItemGroup>
2727

2828

2-WebApp-graph-user/2-4-Sovereign-Call-MSGraph/WebApp-OpenIDConnect-DotNet.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
<None Remove="ReadmeFiles\**" />
1818
</ItemGroup>
1919

20-
<ItemGroup>
21-
<PackageReference Include="Microsoft.Identity.Web.UI" Version="1.25.10" />
22-
<PackageReference Include="Microsoft.Identity.Web.MicrosoftGraph" Version="1.25.10" />
23-
</ItemGroup>
20+
<ItemGroup>
21+
<PackageReference Include="Microsoft.Identity.Web.UI" Version="2.5.0" />
22+
<PackageReference Include="Microsoft.Identity.Web.MicrosoftGraph" Version="2.5.0" />
23+
</ItemGroup>
2424

2525
</Project>

3-WebApp-multi-APIs/WebApp-OpenIDConnect-DotNet.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919

2020
<ItemGroup>
2121
<PackageReference Include="Azure.Storage.Blobs" Version="12.13.0" />
22-
<PackageReference Include="Microsoft.Identity.Web" Version="1.25.10" />
23-
<PackageReference Include="Microsoft.Identity.Web.UI" Version="1.25.10" />
22+
<PackageReference Include="Microsoft.Identity.Web" Version="2.5.0" />
23+
<PackageReference Include="Microsoft.Identity.Web.UI" Version="2.5.0" />
2424
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
2525
</ItemGroup>
2626

4-WebApp-your-API/4-1-MyOrg/Client/Controllers/TodoListController.cs

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,38 @@
33
using Microsoft.Identity.Web;
44
using System.Threading.Tasks;
55
using TodoListService.Models;
6-
using TodoListClient.Services;
6+
using Microsoft.Identity.Abstractions;
7+
using System.Net.Http;
8+
using System.Collections.Generic;
79

810
namespace TodoListClient.Controllers
911
{
12+
// TODO: Change the "c53a1bc4-9757-407d-a76a-51a2032d2afb" GUID
13+
// by the Application ID of the web API
14+
[AuthorizeForScopes(Scopes = new string[]{
15+
"api://c53a1bc4-9757-407d-a76a-51a2032d2afb/ToDoList.Read",
16+
"api://c53a1bc4-9757-407d-a76a-51a2032d2afb/ToDoList.ReadWrite"})]
1017
public class TodoListController : Controller
1118
{
12-
private ITodoListService _todoListService;
19+
private IDownstreamApi _downstreamApi;
1320

14-
public TodoListController(ITodoListService todoListService)
21+
public TodoListController(IDownstreamApi todoListService)
1522
{
16-
_todoListService = todoListService;
23+
_downstreamApi = todoListService;
1724
}
1825

1926
public async Task<ActionResult> Index()
2027
{
21-
var result = await _todoListService.GetAsync();
28+
var result = await _downstreamApi.GetForUserAsync<IEnumerable<Todo>>("TodoList");
2229
return View(result);
2330
}
2431

2532
// GET: TodoList/Details/5
2633
public async Task<ActionResult> Details(int id)
2734
{
28-
return View(await _todoListService.GetAsync(id));
35+
return View(await _downstreamApi.GetForUserAsync<Todo>(
36+
"TodoList",
37+
options => options.RelativePath = $"api/todolist/{id}"));
2938
}
3039

3140
// GET: TodoList/Create
@@ -40,14 +49,16 @@ public ActionResult Create()
4049
[ValidateAntiForgeryToken]
4150
public async Task<ActionResult> Create([Bind("Title,Owner")] Todo todo)
4251
{
43-
await _todoListService.AddAsync(todo);
52+
await _downstreamApi.PostForUserAsync("TodoList", todo);
4453
return RedirectToAction("Index");
4554
}
4655

4756
// GET: TodoList/Edit/5
4857
public async Task<ActionResult> Edit(int id)
4958
{
50-
Todo todo = await this._todoListService.GetAsync(id);
59+
Todo todo = await _downstreamApi.GetForUserAsync<Todo>(
60+
"TodoList",
61+
options => options.RelativePath = $"api/todolist/{id}");
5162

5263
if (todo == null)
5364
{
@@ -62,14 +73,18 @@ public async Task<ActionResult> Edit(int id)
6273
[ValidateAntiForgeryToken]
6374
public async Task<ActionResult> Edit(int id, [Bind("Id,Title,Owner")] Todo todo)
6475
{
65-
await _todoListService.EditAsync(todo);
76+
todo = await _downstreamApi.CallApiForUserAsync<Todo, Todo>(
77+
"TodoList", todo,
78+
options => { options.RelativePath = $"api/todolist/{id}"; options.HttpMethod = HttpMethod.Patch; }) ;
6679
return RedirectToAction("Index");
6780
}
6881

6982
// GET: TodoList/Delete/5
7083
public async Task<ActionResult> DeleteItem(int id)
7184
{
72-
Todo todo = await this._todoListService.GetAsync(id);
85+
Todo todo = await _downstreamApi.GetForUserAsync<Todo>(
86+
"TodoList",
87+
options => options.RelativePath = $"api/todolist/{id}");
7388

7489
if (todo == null)
7590
{
@@ -84,7 +99,8 @@ public async Task<ActionResult> DeleteItem(int id)
8499
[ValidateAntiForgeryToken]
85100
public async Task<ActionResult> DeleteItem(int id, [Bind("Id,Title,Owner")] Todo todo)
86101
{
87-
await _todoListService.DeleteAsync(id);
102+
await _downstreamApi.DeleteForUserAsync("TodoList", todo,
103+
options => options.RelativePath = $"api/todolist/{id}");
88104
return RedirectToAction("Index");
89105
}
90106
}

0 commit comments

Comments
 (0)