Last active
August 28, 2018 09:35
-
-
Save richstokoe/2fa7707efedfe5486a60524be3343f00 to your computer and use it in GitHub Desktop.
Securing AspNetCore SPA Template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.AspNetCore.Authentication; | |
// Configure() | |
app.Use(async (context, next) => | |
{ | |
if (!context.User.Identity.IsAuthenticated) | |
{ | |
await context.ChallengeAsync(); | |
} | |
else | |
{ | |
// Already authenticated, call next middleware | |
await next(); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment