Handle null auth, null descriptions.

This commit is contained in:
Chris Ross 2015-04-23 16:05:05 -07:00
parent 0ed2692ef4
commit 06e24a8fdf
2 changed files with 13 additions and 3 deletions

View File

@ -20,17 +20,17 @@ namespace Microsoft.AspNet.Http.Authentication
/// Initializes a new instance of the <see cref="AuthenticationDescription"/> class
/// </summary>
public AuthenticationDescription()
: this(items: null)
{
Items = new Dictionary<string, object>(StringComparer.Ordinal);
}
/// <summary>
/// Initializes a new instance of the <see cref="AuthenticationDescription"/> class
/// </summary>
/// <param name="items"></param>
public AuthenticationDescription([NotNull] IDictionary<string, object> items)
public AuthenticationDescription(IDictionary<string, object> items)
{
Items = items;
Items = items ?? new Dictionary<string, object>(StringComparer.Ordinal); ;
}
/// <summary>

View File

@ -61,6 +61,11 @@ namespace Microsoft.AspNet.Http.Authentication
throw new InvalidOperationException($"The following authentication scheme was not accepted: {authenticationScheme}");
}
if (authenticateContext.Principal == null)
{
return null;
}
return new AuthenticationResult(authenticateContext.Principal,
new AuthenticationProperties(authenticateContext.Properties),
new AuthenticationDescription(authenticateContext.Description));
@ -82,6 +87,11 @@ namespace Microsoft.AspNet.Http.Authentication
throw new InvalidOperationException($"The following authentication scheme was not accepted: {authenticationScheme}");
}
if (authenticateContext.Principal == null)
{
return null;
}
return new AuthenticationResult(authenticateContext.Principal,
new AuthenticationProperties(authenticateContext.Properties),
new AuthenticationDescription(authenticateContext.Description));