Skip to content

Commit 6626226

Browse files
authored
Replace the scopes in the controller with a reference to appsettings (#696)
* Replace the scopes in the controller with a reference to appsettings * Address possible null warnings
1 parent 508416e commit 6626226

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

2-WebApp-graph-user/2-6-BFF-Proxy/CallGraphBFF/Program.cs

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

1616
// Add Microsoft.Identity.Web services to the container.
1717
builder.Services.AddMicrosoftIdentityWebAppAuthentication(builder.Configuration)
18-
.EnableTokenAcquisitionToCallDownstreamApi(builder.Configuration.GetSection("DownstreamApi:Scopes").Value.Split(' '))
19-
.AddMicrosoftGraph(builder.Configuration.GetValue<string>("DownstreamApi:BaseUrl"), builder.Configuration.GetValue<string>("DownstreamApi:Scopes"))
18+
.EnableTokenAcquisitionToCallDownstreamApi(builder.Configuration.GetSection("DownstreamApi:Scopes").Value!.Split(' '))
19+
.AddMicrosoftGraph(builder.Configuration.GetValue<string>("DownstreamApi:BaseUrl")!, builder.Configuration.GetValue<string>("DownstreamApi:Scopes")!)
2020
.AddInMemoryTokenCaches();
2121

2222
// Add session for sharing non-sensitive strings between routes.

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,7 @@
99

1010
namespace TodoListClient.Controllers
1111
{
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"})]
12+
[AuthorizeForScopes(ScopeKeySection = "TodoList:Scopes")]
1713
public class TodoListController : Controller
1814
{
1915
private IDownstreamApi _downstreamApi;

0 commit comments

Comments
 (0)