This repository was archived by the owner on Nov 20, 2018. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +13
-3
lines changed
Microsoft.AspNet.Http.Core/Authentication
Microsoft.AspNet.Http/Authentication Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -20,17 +20,17 @@ public class AuthenticationDescription
2020 /// Initializes a new instance of the <see cref="AuthenticationDescription"/> class
2121 /// </summary>
2222 public AuthenticationDescription ( )
23+ : this ( items : null )
2324 {
24- Items = new Dictionary < string , object > ( StringComparer . Ordinal ) ;
2525 }
2626
2727 /// <summary>
2828 /// Initializes a new instance of the <see cref="AuthenticationDescription"/> class
2929 /// </summary>
3030 /// <param name="items"></param>
31- public AuthenticationDescription ( [ NotNull ] IDictionary < string , object > items )
31+ public AuthenticationDescription ( IDictionary < string , object > items )
3232 {
33- Items = items ;
33+ Items = items ?? new Dictionary < string , object > ( StringComparer . Ordinal ) ; ;
3434 }
3535
3636 /// <summary>
Original file line number Diff line number Diff line change @@ -61,6 +61,11 @@ public override AuthenticationResult Authenticate([NotNull] string authenticatio
6161 throw new InvalidOperationException ( $ "The following authentication scheme was not accepted: { authenticationScheme } ") ;
6262 }
6363
64+ if ( authenticateContext . Principal == null )
65+ {
66+ return null ;
67+ }
68+
6469 return new AuthenticationResult ( authenticateContext . Principal ,
6570 new AuthenticationProperties ( authenticateContext . Properties ) ,
6671 new AuthenticationDescription ( authenticateContext . Description ) ) ;
@@ -82,6 +87,11 @@ public override async Task<AuthenticationResult> AuthenticateAsync([NotNull] str
8287 throw new InvalidOperationException ( $ "The following authentication scheme was not accepted: { authenticationScheme } ") ;
8388 }
8489
90+ if ( authenticateContext . Principal == null )
91+ {
92+ return null ;
93+ }
94+
8595 return new AuthenticationResult ( authenticateContext . Principal ,
8696 new AuthenticationProperties ( authenticateContext . Properties ) ,
8797 new AuthenticationDescription ( authenticateContext . Description ) ) ;
You can’t perform that action at this time.
0 commit comments