Skip to content

Instantly share code, notes, and snippets.

@jmcd
Created January 4, 2018 09:42
Show Gist options
  • Save jmcd/778f1a45d7d17a12594e3e1e89ca0a53 to your computer and use it in GitHub Desktop.
Save jmcd/778f1a45d7d17a12594e3e1e89ca0a53 to your computer and use it in GitHub Desktop.
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc(config =>
{
var requireAgent = new AuthorizationPolicyBuilder()
.RequireAuthenticatedUser()
.RequireRole(RoleNames.Agent)
.Build();
config.Filters.Add(new AuthorizeFilter(requireAgent));
});
...
[AllowAnonymous]
public class HomeController : Controller
{
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment