Delete old handlers
This commit is contained in:
parent
434d158c76
commit
dbdabeb9d2
|
|
@ -1,32 +0,0 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Authorization
|
|
||||||
{
|
|
||||||
public class ClaimsAuthorizationHandler : AuthorizationHandler<ClaimsAuthorizationRequirement>
|
|
||||||
{
|
|
||||||
public override void Handle(AuthorizationContext context, ClaimsAuthorizationRequirement requirement)
|
|
||||||
{
|
|
||||||
if (context.User != null)
|
|
||||||
{
|
|
||||||
bool found = false;
|
|
||||||
if (requirement.AllowedValues == null || !requirement.AllowedValues.Any())
|
|
||||||
{
|
|
||||||
found = context.User.Claims.Any(c => string.Equals(c.Type, requirement.ClaimType, StringComparison.OrdinalIgnoreCase));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
found = context.User.Claims.Any(c => string.Equals(c.Type, requirement.ClaimType, StringComparison.OrdinalIgnoreCase)
|
|
||||||
&& requirement.AllowedValues.Contains(c.Value, StringComparer.Ordinal));
|
|
||||||
}
|
|
||||||
if (found)
|
|
||||||
{
|
|
||||||
context.Succeed(requirement);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,22 +0,0 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
|
||||||
|
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Authorization
|
|
||||||
{
|
|
||||||
public class DenyAnonymousAuthorizationHandler : AuthorizationHandler<DenyAnonymousAuthorizationRequirement>
|
|
||||||
{
|
|
||||||
public override void Handle(AuthorizationContext context, DenyAnonymousAuthorizationRequirement requirement)
|
|
||||||
{
|
|
||||||
var user = context.User;
|
|
||||||
var userIsAnonymous =
|
|
||||||
user?.Identity == null ||
|
|
||||||
!user.Identities.Any(i => i.IsAuthenticated);
|
|
||||||
if (!userIsAnonymous)
|
|
||||||
{
|
|
||||||
context.Succeed(requirement);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue