Skip to content

Instantly share code, notes, and snippets.

@richstokoe
Last active August 28, 2018 09:35
Show Gist options
  • Save richstokoe/2fa7707efedfe5486a60524be3343f00 to your computer and use it in GitHub Desktop.
Save richstokoe/2fa7707efedfe5486a60524be3343f00 to your computer and use it in GitHub Desktop.
Securing AspNetCore SPA Template
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