Skip to content

Instantly share code, notes, and snippets.

@grumpydev
Created February 23, 2011 19:26
Show Gist options
  • Save grumpydev/840985 to your computer and use it in GitHub Desktop.
Save grumpydev/840985 to your computer and use it in GitHub Desktop.
NancyFx claims based authentication demo module.
namespace NancyAuthenticationDemo
{
using Extensions;
using Models;
using Nancy;
/// <summary>
/// A module that only people with SuperSecure clearance are allowed to access
/// </summary>
public class VerySecureModule : NancyModule
{
public VerySecureModule() : base("/superSecure")
{
this.Before += Security.RequiresAuthentication;
this.Before += Security.RequiresClaims(new[] { "SuperSecure" });
Get["/"] = x =>
{
var model = new UserModel(Context.Items["username"].ToString());
return View["superSecure.cshtml", model];
};
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment