{"action":"created","issue":{"url":"https://api.github.com/repos/aspnet/Security/issues/631","labels_url":"https://api.github.com/repos/aspnet/Security/issues/631/labels{/name}","comments_url":"https://api.github.com/repos/aspnet/Security/issues/631/comments","events_url":"https://api.github.com/repos/aspnet/Security/issues/631/events","html_url":"https://github.com/aspnet/Security/issues/631","id":123708322,"number":631,"title":"Reminder to look at sugar for AuthorizationContext.Succeed","user":{"login":"brockallen","id":649492,"avatar_url":"https://avatars.githubusercontent.com/u/649492?v=3","gravatar_id":"","url":"https://api.github.com/users/brockallen","html_url":"https://github.com/brockallen","followers_url":"https://api.github.com/users/brockallen/followers","following_url":"https://api.github.com/users/brockallen/following{/other_user}","gists_url":"https://api.github.com/users/brockallen/gists{/gist_id}","starred_url":"https://api.github.com/users/brockallen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brockallen/subscriptions","organizations_url":"https://api.github.com/users/brockallen/orgs","repos_url":"https://api.github.com/users/brockallen/repos","events_url":"https://api.github.com/users/brockallen/events{/privacy}","received_events_url":"https://api.github.com/users/brockallen/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"HaoK","id":6537861,"avatar_url":"https://avatars.githubusercontent.com/u/6537861?v=3","gravatar_id":"","url":"https://api.github.com/users/HaoK","html_url":"https://github.com/HaoK","followers_url":"https://api.github.com/users/HaoK/followers","following_url":"https://api.github.com/users/HaoK/following{/other_user}","gists_url":"https://api.github.com/users/HaoK/gists{/gist_id}","starred_url":"https://api.github.com/users/HaoK/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HaoK/subscriptions","organizations_url":"https://api.github.com/users/HaoK/orgs","repos_url":"https://api.github.com/users/HaoK/repos","events_url":"https://api.github.com/users/HaoK/events{/privacy}","received_events_url":"https://api.github.com/users/HaoK/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/aspnet/Security/milestones/14","html_url":"https://github.com/aspnet/Security/milestones/1.0.0-rc2","labels_url":"https://api.github.com/repos/aspnet/Security/milestones/14/labels","id":1367318,"number":14,"title":"1.0.0-rc2","description":null,"creator":{"login":"Eilon","id":202643,"avatar_url":"https://avatars.githubusercontent.com/u/202643?v=3","gravatar_id":"","url":"https://api.github.com/users/Eilon","html_url":"https://github.com/Eilon","followers_url":"https://api.github.com/users/Eilon/followers","following_url":"https://api.github.com/users/Eilon/following{/other_user}","gists_url":"https://api.github.com/users/Eilon/gists{/gist_id}","starred_url":"https://api.github.com/users/Eilon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Eilon/subscriptions","organizations_url":"https://api.github.com/users/Eilon/orgs","repos_url":"https://api.github.com/users/Eilon/repos","events_url":"https://api.github.com/users/Eilon/events{/privacy}","received_events_url":"https://api.github.com/users/Eilon/received_events","type":"User","site_admin":false},"open_issues":13,"closed_issues":28,"state":"open","created_at":"2015-10-20T22:41:25Z","updated_at":"2015-12-28T10:58:01Z","due_on":null,"closed_at":null},"comments":7,"created_at":"2015-12-23T18:59:18Z","updated_at":"2015-12-29T21:28:39Z","closed_at":null,"body":"For these scenarios:\r\n\r\n```\r\npublic class AlbumEditHandler : AuthorizationHandler<OperationAuthorizationRequirement, Album>\r\n{\r\n    protected override void Handle(\r\n        AuthorizationContext context,\r\n        OperationAuthorizationRequirement requirement,\r\n        Album resource)\r\n    {\r\n        if (requirement == AlbumAuthorization.Edit)\r\n        {\r\n            if (context.User.IsInRole(\"Employee\") ||\r\n            context.User.FindFirst(\"username\").Value == resource.Owner)\r\n            {\r\n                context.Succeed(requirement);\r\n            }\r\n        }\r\n    }\r\n}\r\n```\r\n\r\nand this:\r\n\r\n```\r\nconfig.AddPolicy(\"PayingCustomer\", builder =>\r\n{\r\n    builder\r\n        .RequireAuthenticatedUser()\r\n        .RequireClaim(\"role\", \"Customer\")\r\n        .RequireDelegate((ctx, r) =>\r\n        {\r\n            var endDateClaim = ctx.User.FindFirst(\"SubscriptionEndDate\");\r\n            if (endDateClaim != null)\r\n            {\r\n                var endDate = DateTime.Parse(endDateClaim.Value);\r\n                if (DateTime.Now <= endDate)\r\n                {\r\n                    ctx.Succeed(r);\r\n                }\r\n            }\r\n        });\r\n});\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/aspnet/Security/issues/comments/167881440","html_url":"https://github.com/aspnet/Security/issues/631#issuecomment-167881440","issue_url":"https://api.github.com/repos/aspnet/Security/issues/631","id":167881440,"user":{"login":"blowdart","id":796298,"avatar_url":"https://avatars.githubusercontent.com/u/796298?v=3","gravatar_id":"","url":"https://api.github.com/users/blowdart","html_url":"https://github.com/blowdart","followers_url":"https://api.github.com/users/blowdart/followers","following_url":"https://api.github.com/users/blowdart/following{/other_user}","gists_url":"https://api.github.com/users/blowdart/gists{/gist_id}","starred_url":"https://api.github.com/users/blowdart/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/blowdart/subscriptions","organizations_url":"https://api.github.com/users/blowdart/orgs","repos_url":"https://api.github.com/users/blowdart/repos","events_url":"https://api.github.com/users/blowdart/events{/privacy}","received_events_url":"https://api.github.com/users/blowdart/received_events","type":"User","site_admin":false},"created_at":"2015-12-29T21:28:38Z","updated_at":"2015-12-29T21:28:38Z","body":"I think you should do something about .Succeed() overriding everything. That is too easy to screw up. People will do that by default and wonder why things are succeeding when other requirements don't."}}