File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change 66using Microsoft . AspNetCore . Mvc ;
77using Microsoft . AspNetCore . Mvc . Filters ;
88using Microsoft . Extensions . DependencyInjection ;
9+ using Microsoft . Extensions . Configuration ;
910
1011namespace Json2Kafka . BasicAuth
1112{
1213 public class BasicAuthFilter : IAuthorizationFilter
1314 {
1415 private readonly string _realm ;
15- public BasicAuthFilter ( string realm )
16+ private readonly IConfiguration _Configuration ;
17+ public BasicAuthFilter ( string realm , IConfiguration Configuration )
1618 {
19+ _Configuration = Configuration ;
1720 _realm = realm ;
1821 if ( string . IsNullOrWhiteSpace ( _realm ) )
1922 {
@@ -42,8 +45,10 @@ public void OnAuthorization(AuthorizationFilterContext context)
4245 }
4346 }
4447 }
45-
46- ReturnUnauthorizedResult ( context ) ;
48+ if ( bool . Parse ( _Configuration [ "BasicAuthEnabled" ] ) )
49+ {
50+ ReturnUnauthorizedResult ( context ) ;
51+ }
4752 }
4853 catch ( FormatException )
4954 {
You can’t perform that action at this time.
0 commit comments