Skip to content
This repository was archived by the owner on Nov 20, 2018. It is now read-only.

Commit dd676ed

Browse files
committed
Make AuthenticationManager async mostly
1 parent c602f04 commit dd676ed

File tree

3 files changed

+5
-9
lines changed

3 files changed

+5
-9
lines changed

src/Microsoft.AspNet.Http.Abstractions/Authentication/AuthenticationManager.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

4-
using System;
54
using System.Collections.Generic;
65
using System.Security.Claims;
76
using System.Threading.Tasks;
@@ -48,14 +47,15 @@ public Task SignInAsync(string authenticationScheme, ClaimsPrincipal principal)
4847
return SignInAsync(authenticationScheme, principal, properties: null);
4948
}
5049

51-
public Task ForbidAsync(string authenticationScheme, AuthenticationProperties properties)
50+
public Task ForbidAsync(string authenticationScheme)
5251
{
53-
return ChallengeAsync(authenticationScheme, properties, ChallengeBehavior.Forbidden);
52+
return ForbidAsync(authenticationScheme, properties: null);
5453
}
5554

56-
public Task ForbidAsync(string authenticationScheme)
55+
// Deny access (typically a 403)
56+
public Task ForbidAsync(string authenticationScheme, AuthenticationProperties properties)
5757
{
58-
return ForbidAsync(authenticationScheme, properties: null);
58+
return ChallengeAsync(authenticationScheme, properties, ChallengeBehavior.Forbidden);
5959
}
6060

6161
public abstract Task ChallengeAsync(string authenticationScheme, AuthenticationProperties properties, ChallengeBehavior behavior);

src/Microsoft.AspNet.Http/Authentication/DefaultAuthenticationManager.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,6 @@ public override async Task AuthenticateAsync([NotNull] AuthenticateContext conte
6565

6666
public override async Task ChallengeAsync([NotNull] string authenticationScheme, AuthenticationProperties properties, ChallengeBehavior behavior)
6767
{
68-
// TODO: move this somewhere else
69-
HttpResponseFeature.StatusCode = 401;
70-
7168
var handler = HttpAuthenticationFeature.Handler;
7269

7370
var challengeContext = new ChallengeContext(authenticationScheme, properties?.Items, behavior);

test/Microsoft.AspNet.Http.Tests/Authentication/DefaultAuthenticationManagerTests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ public async Task ChallengeWithNoAuthMiddlewareMayThrow()
2727
var context = CreateContext();
2828
await context.Authentication.ChallengeAsync();
2929
Assert.Equal(200, context.Response.StatusCode);
30-
3130
await Assert.ThrowsAsync<InvalidOperationException>(() => context.Authentication.ChallengeAsync("Foo"));
3231
}
3332

0 commit comments

Comments
 (0)