Skip to content

Instantly share code, notes, and snippets.

@charlessolar
Created May 10, 2014 13:05
Show Gist options
  • Save charlessolar/276268cc7be52994fb45 to your computer and use it in GitHub Desktop.
Save charlessolar/276268cc7be52994fb45 to your computer and use it in GitHub Desktop.
Concept of C# fluent security that I am implementing in NES.RavenDB.Example
public class Security : IDescriptor
{
public Security()
{
// Action Target Securable
When.Receiving().Queries().OfType<Queries.GetItem>()
// Actors
.Allow(x => x.Users()
// Rule
.WithPermission("GetItems"))
.Allow(x => x.Groups().WithPermission("GetItems"))
.Deny(x => x.Users().Having(u => u.Username.BeginsWith("John")));
When.Executing().Functions().InNamespace("SecureSpace")
.Allow(x => x.Users().Having(u => u.Username.BeginsWith("Admin")));
When.Reading().Properties().Inside<Queries.GetItem>("Number")
.Allow(x => x.Services().InNamespace("Inventory"))
.Deny(x => x.Users().Having(u => u.Username.BeginsWith("John")));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment