Created
May 10, 2014 13:05
-
-
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
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
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