Created
February 23, 2011 19:26
-
-
Save grumpydev/840985 to your computer and use it in GitHub Desktop.
NancyFx claims based authentication demo module.
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
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