#53 - Reduce auth exceptions for missing handlers.
This commit is contained in:
parent
be5a98d38f
commit
cfe76de294
|
|
@ -153,13 +153,12 @@ namespace Microsoft.AspNet.PipelineCore
|
||||||
throw new ArgumentNullException();
|
throw new ArgumentNullException();
|
||||||
}
|
}
|
||||||
var handler = HttpAuthentication.Handler;
|
var handler = HttpAuthentication.Handler;
|
||||||
if (handler == null)
|
|
||||||
{
|
|
||||||
throw new InvalidOperationException("No authentication handlers present.");
|
|
||||||
}
|
|
||||||
|
|
||||||
var authenticateContext = new AuthenticateContext(authenticationTypes);
|
var authenticateContext = new AuthenticateContext(authenticationTypes);
|
||||||
handler.Authenticate(authenticateContext);
|
if (handler != null)
|
||||||
|
{
|
||||||
|
handler.Authenticate(authenticateContext);
|
||||||
|
}
|
||||||
|
|
||||||
// Verify all types ack'd
|
// Verify all types ack'd
|
||||||
IEnumerable<string> leftovers = authenticationTypes.Except(authenticateContext.Accepted);
|
IEnumerable<string> leftovers = authenticationTypes.Except(authenticateContext.Accepted);
|
||||||
|
|
@ -178,13 +177,12 @@ namespace Microsoft.AspNet.PipelineCore
|
||||||
throw new ArgumentNullException();
|
throw new ArgumentNullException();
|
||||||
}
|
}
|
||||||
var handler = HttpAuthentication.Handler;
|
var handler = HttpAuthentication.Handler;
|
||||||
if (handler == null)
|
|
||||||
{
|
|
||||||
throw new InvalidOperationException("No authentication handlers present.");
|
|
||||||
}
|
|
||||||
|
|
||||||
var authenticateContext = new AuthenticateContext(authenticationTypes);
|
var authenticateContext = new AuthenticateContext(authenticationTypes);
|
||||||
await handler.AuthenticateAsync(authenticateContext);
|
if (handler != null)
|
||||||
|
{
|
||||||
|
await handler.AuthenticateAsync(authenticateContext);
|
||||||
|
}
|
||||||
|
|
||||||
// Verify all types ack'd
|
// Verify all types ack'd
|
||||||
IEnumerable<string> leftovers = authenticationTypes.Except(authenticateContext.Accepted);
|
IEnumerable<string> leftovers = authenticationTypes.Except(authenticateContext.Accepted);
|
||||||
|
|
|
||||||
|
|
@ -135,13 +135,12 @@ namespace Microsoft.AspNet.PipelineCore
|
||||||
}
|
}
|
||||||
HttpResponseInformation.StatusCode = 401;
|
HttpResponseInformation.StatusCode = 401;
|
||||||
var handler = HttpAuthentication.Handler;
|
var handler = HttpAuthentication.Handler;
|
||||||
if (handler == null)
|
|
||||||
{
|
|
||||||
throw new InvalidOperationException("No authentication handlers present.");
|
|
||||||
}
|
|
||||||
|
|
||||||
var challengeContext = new ChallengeContext(authenticationTypes, properties == null ? null : properties.Dictionary);
|
var challengeContext = new ChallengeContext(authenticationTypes, properties == null ? null : properties.Dictionary);
|
||||||
handler.Challenge(challengeContext);
|
if (handler != null)
|
||||||
|
{
|
||||||
|
handler.Challenge(challengeContext);
|
||||||
|
}
|
||||||
|
|
||||||
// Verify all types ack'd
|
// Verify all types ack'd
|
||||||
IEnumerable<string> leftovers = authenticationTypes.Except(challengeContext.Accepted);
|
IEnumerable<string> leftovers = authenticationTypes.Except(challengeContext.Accepted);
|
||||||
|
|
@ -158,13 +157,12 @@ namespace Microsoft.AspNet.PipelineCore
|
||||||
throw new ArgumentNullException();
|
throw new ArgumentNullException();
|
||||||
}
|
}
|
||||||
var handler = HttpAuthentication.Handler;
|
var handler = HttpAuthentication.Handler;
|
||||||
if (handler == null)
|
|
||||||
{
|
|
||||||
throw new InvalidOperationException("No authentication handlers present.");
|
|
||||||
}
|
|
||||||
|
|
||||||
var signInContext = new SignInContext(identities, properties == null ? null : properties.Dictionary);
|
var signInContext = new SignInContext(identities, properties == null ? null : properties.Dictionary);
|
||||||
handler.SignIn(signInContext);
|
if (handler != null)
|
||||||
|
{
|
||||||
|
handler.SignIn(signInContext);
|
||||||
|
}
|
||||||
|
|
||||||
// Verify all types ack'd
|
// Verify all types ack'd
|
||||||
IEnumerable<string> leftovers = identities.Select(identity => identity.AuthenticationType).Except(signInContext.Accepted);
|
IEnumerable<string> leftovers = identities.Select(identity => identity.AuthenticationType).Except(signInContext.Accepted);
|
||||||
|
|
@ -181,13 +179,12 @@ namespace Microsoft.AspNet.PipelineCore
|
||||||
throw new ArgumentNullException();
|
throw new ArgumentNullException();
|
||||||
}
|
}
|
||||||
var handler = HttpAuthentication.Handler;
|
var handler = HttpAuthentication.Handler;
|
||||||
if (handler == null)
|
|
||||||
{
|
|
||||||
throw new InvalidOperationException("No authentication handlers present.");
|
|
||||||
}
|
|
||||||
|
|
||||||
var signOutContext = new SignOutContext(authenticationTypes);
|
var signOutContext = new SignOutContext(authenticationTypes);
|
||||||
handler.SignOut(signOutContext);
|
if (handler != null)
|
||||||
|
{
|
||||||
|
handler.SignOut(signOutContext);
|
||||||
|
}
|
||||||
|
|
||||||
// Verify all types ack'd
|
// Verify all types ack'd
|
||||||
IEnumerable<string> leftovers = authenticationTypes.Except(signOutContext.Accepted);
|
IEnumerable<string> leftovers = authenticationTypes.Except(signOutContext.Accepted);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue