4
4
using System ;
5
5
using System . Collections . Generic ;
6
6
using System . Diagnostics . Contracts ;
7
+ using System . Linq ;
7
8
using System . Threading ;
8
9
using System . Threading . Tasks ;
9
10
using Microsoft . AspNetCore . Authentication ;
@@ -33,7 +34,7 @@ internal class MessagePump : IServer
33
34
34
35
private readonly ServerAddressesFeature _serverAddresses ;
35
36
36
- public MessagePump ( IOptions < HttpSysOptions > options , ILoggerFactory loggerFactory , IAuthenticationSchemeProvider authentication )
37
+ public MessagePump ( IOptions < HttpSysOptions > options , ILoggerFactory loggerFactory , IEnumerable < IAuthenticationSchemeProvider > authentication )
37
38
{
38
39
if ( options == null )
39
40
{
@@ -43,16 +44,20 @@ public MessagePump(IOptions<HttpSysOptions> options, ILoggerFactory loggerFactor
43
44
{
44
45
throw new ArgumentNullException ( nameof ( loggerFactory ) ) ;
45
46
}
46
- if ( authentication == null )
47
- {
48
- throw new ArgumentNullException ( nameof ( authentication ) ) ;
49
- }
50
-
51
47
_options = options . Value ;
52
48
Listener = new HttpSysListener ( _options , loggerFactory ) ;
53
49
_logger = LogHelper . CreateLogger ( loggerFactory , typeof ( MessagePump ) ) ;
54
50
55
- AddSchemes ( authentication , _options . Authentication . Schemes ) ;
51
+ if ( _options . Authentication . Schemes != AuthenticationSchemes . None )
52
+ {
53
+ var auth = authentication . FirstOrDefault ( ) ;
54
+ if ( auth == null )
55
+ {
56
+ throw new InvalidOperationException ( "AddAuthentication() is required to use Authentication." ) ;
57
+ }
58
+
59
+ AddSchemes ( auth , _options . Authentication . Schemes ) ;
60
+ }
56
61
57
62
Features = new FeatureCollection ( ) ;
58
63
_serverAddresses = new ServerAddressesFeature ( ) ;
0 commit comments