Challenge now always checks for accept
This commit is contained in:
parent
4576481a32
commit
67803d2f41
|
|
@ -72,8 +72,7 @@ namespace Microsoft.AspNet.Http.Authentication.Internal
|
||||||
await handler.ChallengeAsync(challengeContext);
|
await handler.ChallengeAsync(challengeContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
// The default Challenge with no scheme is always accepted
|
if (!challengeContext.Accepted)
|
||||||
if (!challengeContext.Accepted && !string.IsNullOrEmpty(authenticationScheme))
|
|
||||||
{
|
{
|
||||||
throw new InvalidOperationException($"The following authentication scheme was not accepted: {authenticationScheme}");
|
throw new InvalidOperationException($"The following authentication scheme was not accepted: {authenticationScheme}");
|
||||||
}
|
}
|
||||||
|
|
@ -105,7 +104,7 @@ namespace Microsoft.AspNet.Http.Authentication.Internal
|
||||||
await handler.SignOutAsync(signOutContext);
|
await handler.SignOutAsync(signOutContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(authenticationScheme) && !signOutContext.Accepted)
|
if (!signOutContext.Accepted)
|
||||||
{
|
{
|
||||||
throw new InvalidOperationException($"The following authentication scheme was not accepted: {authenticationScheme}");
|
throw new InvalidOperationException($"The following authentication scheme was not accepted: {authenticationScheme}");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,13 +21,14 @@ namespace Microsoft.AspNet.Http.Authentication.Internal
|
||||||
await Assert.ThrowsAsync<InvalidOperationException>(async () => await context.Authentication.AuthenticateAsync("Foo"));
|
await Assert.ThrowsAsync<InvalidOperationException>(async () => await context.Authentication.AuthenticateAsync("Foo"));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Theory]
|
||||||
public async Task ChallengeWithNoAuthMiddlewareMayThrow()
|
[InlineData("")]
|
||||||
|
[InlineData(null)]
|
||||||
|
[InlineData("Foo")]
|
||||||
|
public async Task ChallengeWithNoAuthMiddlewareMayThrow(string scheme)
|
||||||
{
|
{
|
||||||
var context = CreateContext();
|
var context = CreateContext();
|
||||||
await context.Authentication.ChallengeAsync();
|
await Assert.ThrowsAsync<InvalidOperationException>(() => context.Authentication.ChallengeAsync(scheme));
|
||||||
Assert.Equal(200, context.Response.StatusCode);
|
|
||||||
await Assert.ThrowsAsync<InvalidOperationException>(() => context.Authentication.ChallengeAsync("Foo"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue