Skip to content

Instantly share code, notes, and snippets.

@pmhsfelix
Created September 4, 2012 00:45
Show Gist options
  • Save pmhsfelix/3615356 to your computer and use it in GitHub Desktop.
Save pmhsfelix/3615356 to your computer and use it in GitHub Desktop.
Playing with claims and boolean operator overloading
[Fact]
public void Fact1()
{
var namedAlice = new UserNameClaim("Alice");
var teacher = new RoleClaim("Teacher");
var student = new RoleClaim("Student");
var alice = Claims.Identity(new UserNameClaim("Alice"), student);
var bob = Claims.Identity(new UserNameClaim("Bob"), teacher);
var anotherAlice = Claims.Identity(new UserNameClaim("Alice"));
var authorized = (namedAlice && student) || teacher;
Assert.True(alice.Is(authorized));
Assert.True(bob.Is(authorized));
Assert.False(anotherAlice.Is(authorized));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment