Handle null auth, null descriptions.
This commit is contained in:
parent
0ed2692ef4
commit
06e24a8fdf
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
|
|
|
|||
Loading…
Reference in New Issue