diff --git a/src/Microsoft.AspNet.Authorization/AuthorizationServiceExtensions.cs b/src/Microsoft.AspNet.Authorization/AuthorizationServiceExtensions.cs
index 14951fa075..27b74c4a5b 100644
--- a/src/Microsoft.AspNet.Authorization/AuthorizationServiceExtensions.cs
+++ b/src/Microsoft.AspNet.Authorization/AuthorizationServiceExtensions.cs
@@ -58,55 +58,5 @@ namespace Microsoft.AspNet.Authorization
{
return service.AuthorizeAsync(user, resource: null, policyName: policyName);
}
-
- ///
- /// Checks if a user meets a specific requirement for the specified resource
- ///
- ///
- ///
- ///
- ///
- public static bool Authorize([NotNull] this IAuthorizationService service, ClaimsPrincipal user, object resource, [NotNull] IAuthorizationRequirement requirement)
- {
- return service.Authorize(user, resource, new IAuthorizationRequirement[] { requirement });
- }
-
- ///
- /// Checks if a user meets a specific authorization policy
- ///
- /// The authorization service.
- /// The user to check the policy against.
- /// The resource the policy should be checked with.
- /// The policy to check against a specific context.
- /// true when the user fulfills the policy, false otherwise.
- public static bool Authorize([NotNull] this IAuthorizationService service, ClaimsPrincipal user, object resource, [NotNull] AuthorizationPolicy policy)
- {
- return service.Authorize(user, resource, policy.Requirements.ToArray());
- }
-
- ///
- /// Checks if a user meets a specific authorization policy
- ///
- /// The authorization service.
- /// The user to check the policy against.
- /// The policy to check against a specific context.
- /// true when the user fulfills the policy, false otherwise.
- public static bool Authorize([NotNull] this IAuthorizationService service, ClaimsPrincipal user, [NotNull] AuthorizationPolicy policy)
- {
- return service.Authorize(user, resource: null, requirements: policy.Requirements.ToArray());
- }
-
- ///
- /// Checks if a user meets a specific authorization policy
- ///
- /// The authorization service.
- /// The user to check the policy against.
- /// The name of the policy to check against a specific context.
- /// true when the user fulfills the policy, false otherwise.
- public static bool Authorize([NotNull] this IAuthorizationService service, ClaimsPrincipal user, [NotNull] string policyName)
- {
- return service.Authorize(user, resource: null, policyName: policyName);
- }
-
}
}
\ No newline at end of file
diff --git a/src/Microsoft.AspNet.Authorization/DefaultAuthorizationService.cs b/src/Microsoft.AspNet.Authorization/DefaultAuthorizationService.cs
index bb3d888298..522b9d3231 100644
--- a/src/Microsoft.AspNet.Authorization/DefaultAuthorizationService.cs
+++ b/src/Microsoft.AspNet.Authorization/DefaultAuthorizationService.cs
@@ -21,25 +21,6 @@ namespace Microsoft.AspNet.Authorization
_options = options.Options;
}
- public bool Authorize(ClaimsPrincipal user, object resource, string policyName)
- {
- var policy = _options.GetPolicy(policyName);
- return (policy == null)
- ? false
- : this.Authorize(user, resource, policy);
- }
-
- public bool Authorize(ClaimsPrincipal user, object resource, [NotNull] IEnumerable requirements)
- {
- var authContext = new AuthorizationContext(requirements, user, resource);
- foreach (var handler in _handlers)
- {
- handler.Handle(authContext);
- //REVIEW: Do we want to consider short circuiting on failure
- }
- return authContext.HasSucceeded;
- }
-
public async Task AuthorizeAsync(ClaimsPrincipal user, object resource, [NotNull] IEnumerable requirements)
{
var authContext = new AuthorizationContext(requirements, user, resource);
diff --git a/src/Microsoft.AspNet.Authorization/IAuthorizationHandler.cs b/src/Microsoft.AspNet.Authorization/IAuthorizationHandler.cs
index b4366a6f51..84ebbc9a3e 100644
--- a/src/Microsoft.AspNet.Authorization/IAuthorizationHandler.cs
+++ b/src/Microsoft.AspNet.Authorization/IAuthorizationHandler.cs
@@ -8,6 +8,5 @@ namespace Microsoft.AspNet.Authorization
public interface IAuthorizationHandler
{
Task HandleAsync(AuthorizationContext context);
- void Handle(AuthorizationContext context);
}
}
diff --git a/src/Microsoft.AspNet.Authorization/IAuthorizationService.cs b/src/Microsoft.AspNet.Authorization/IAuthorizationService.cs
index 876fd76016..1afa0ae5dd 100644
--- a/src/Microsoft.AspNet.Authorization/IAuthorizationService.cs
+++ b/src/Microsoft.AspNet.Authorization/IAuthorizationService.cs
@@ -22,15 +22,6 @@ namespace Microsoft.AspNet.Authorization
///
Task AuthorizeAsync(ClaimsPrincipal user, object resource, [NotNull] IEnumerable requirements);
- ///
- /// Checks if a user meets a specific set of requirements for the specified resource
- ///
- ///
- ///
- ///
- ///
- bool Authorize(ClaimsPrincipal user, object resource, [NotNull] IEnumerable requirements);
-
///
/// Checks if a user meets a specific authorization policy
///
@@ -39,14 +30,5 @@ namespace Microsoft.AspNet.Authorization
/// The name of the policy to check against a specific context.
/// true when the user fulfills the policy, false otherwise.
Task AuthorizeAsync(ClaimsPrincipal user, object resource, [NotNull] string policyName);
-
- ///
- /// Checks if a user meets a specific authorization policy
- ///
- /// The user to check the policy against.
- /// The resource the policy should be checked with.
- /// The name of the policy to check against a specific context.
- /// true when the user fulfills the policy, false otherwise.
- bool Authorize(ClaimsPrincipal user, object resource, [NotNull] string policyName);
}
}
\ No newline at end of file
diff --git a/src/Microsoft.AspNet.Authorization/PassThroughAuthorizationHandler.cs b/src/Microsoft.AspNet.Authorization/PassThroughAuthorizationHandler.cs
index 93107cc6bd..b1d3b84210 100644
--- a/src/Microsoft.AspNet.Authorization/PassThroughAuthorizationHandler.cs
+++ b/src/Microsoft.AspNet.Authorization/PassThroughAuthorizationHandler.cs
@@ -15,13 +15,5 @@ namespace Microsoft.AspNet.Authorization
await handler.HandleAsync(context);
}
}
-
- public void Handle(AuthorizationContext context)
- {
- foreach (var handler in context.Requirements.OfType())
- {
- handler.Handle(context);
- }
- }
}
}
diff --git a/test/Microsoft.AspNet.Authorization.Test/DefaultAuthorizationServiceTests.cs b/test/Microsoft.AspNet.Authorization.Test/DefaultAuthorizationServiceTests.cs
index a3d9c21b14..d67ff91637 100644
--- a/test/Microsoft.AspNet.Authorization.Test/DefaultAuthorizationServiceTests.cs
+++ b/test/Microsoft.AspNet.Authorization.Test/DefaultAuthorizationServiceTests.cs
@@ -831,7 +831,7 @@ namespace Microsoft.AspNet.Authorization.Test
}
[Fact]
- public void CanAuthorizeWithDelegateRequirement()
+ public async Task CanAuthorizeWithDelegateRequirement()
{
var authorizationService = BuildAuthorizationService(services =>
{
@@ -843,7 +843,7 @@ namespace Microsoft.AspNet.Authorization.Test
var user = new ClaimsPrincipal();
// Act
- var allowed = authorizationService.Authorize(user, "Basic");
+ var allowed = await authorizationService.AuthorizeAsync(user, "Basic");
// Assert
Assert.True(allowed);