File tree Expand file tree Collapse file tree 4 files changed +8
-8
lines changed
4-WebApp-your-API/4-3-AnyOrg Expand file tree Collapse file tree 4 files changed +8
-8
lines changed Original file line number Diff line number Diff line change 15
15
16
16
namespace ToDoListClient . Controllers
17
17
{
18
+ [ Authorize ]
18
19
public class ToDoListController : Controller
19
20
{
20
21
private IToDoListService _todoListService ;
@@ -24,7 +25,6 @@ public ToDoListController(IToDoListService todoListService)
24
25
_todoListService = todoListService ;
25
26
}
26
27
// GET: TodoList
27
- [ AuthorizeForScopes ( ScopeKeySection = "TodoList:TodoListScope" ) ]
28
28
public async Task < ActionResult > Index ( )
29
29
{
30
30
Original file line number Diff line number Diff line change @@ -33,9 +33,9 @@ public void ConfigureServices(IServiceCollection services)
33
33
// Handling SameSite cookie according to https://docs.microsoft.com/en-us/aspnet/core/security/samesite?view=aspnetcore-3.1
34
34
options . HandleSameSiteCookieCompatibility ( ) ;
35
35
} ) ;
36
- services . AddSignIn ( Configuration ) .
37
- AddWebAppCallsProtectedWebApi ( Configuration , new string [ ] { Configuration [ "TodoList:TodoListScope" ] } ) .
38
- AddInMemoryTokenCaches ( ) ;
36
+ services . AddSignIn ( Configuration )
37
+ . AddWebAppCallsProtectedWebApi ( Configuration , new string [ ] { Configuration [ "TodoList:TodoListScope" ] } )
38
+ . AddInMemoryTokenCaches ( ) ;
39
39
services . AddTodoListService ( Configuration ) ;
40
40
services . AddControllersWithViews ( options =>
41
41
{
Original file line number Diff line number Diff line change @@ -65,7 +65,7 @@ public async Task<ActionResult<TodoItem>> GetTodoItem(int id)
65
65
66
66
return todoItem ;
67
67
}
68
- [ HttpGet ( "/api/todolist/ getallusers" ) ]
68
+ [ HttpGet ( "getallusers" ) ]
69
69
public async Task < ActionResult < IEnumerable < string > > > GetAllTodoItem ( )
70
70
{
71
71
HttpContext . VerifyUserHasAnyAcceptedScope ( scopeRequiredByApi ) ;
@@ -169,7 +169,7 @@ public async Task<List<string>> CallGraphApiOnBehalfOfUser()
169
169
catch ( MsalUiRequiredException ex )
170
170
{
171
171
_tokenAcquisition . ReplyForbiddenWithWwwAuthenticateHeader ( scopes , ex ) ;
172
- return null ;
172
+ throw ( ex ) ;
173
173
}
174
174
}
175
175
private static async Task < IEnumerable < User > > CallGraphApiOnBehalfOfUser ( string accessToken )
Original file line number Diff line number Diff line change @@ -27,8 +27,8 @@ public void ConfigureServices(IServiceCollection services)
27
27
{
28
28
// Setting configuration for protected web api
29
29
30
- services . AddAuthentication ( JwtBearerDefaults . AuthenticationScheme ) .
31
- AddProtectedWebApi ( Configuration ) ;
30
+ services . AddAuthentication ( JwtBearerDefaults . AuthenticationScheme )
31
+ . AddProtectedWebApi ( Configuration ) ;
32
32
33
33
// Comment above lines of code and uncomment this section if you would like to validate ID tokens for allowed tenantIds
34
34
//services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
You can’t perform that action at this time.
0 commit comments