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

Commit

Permalink
Handle null auth, null descriptions.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tratcher committed Apr 23, 2015
1 parent 0ed2692 commit 06e24a8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ public class AuthenticationDescription
/// 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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ public override AuthenticationResult Authenticate([NotNull] string authenticatio
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));
Expand All @@ -82,6 +87,11 @@ public override async Task<AuthenticationResult> AuthenticateAsync([NotNull] str
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));
Expand Down

0 comments on commit 06e24a8

Please sign in to comment.