@@ -12,7 +12,7 @@ public class BasicAuthenticationFilter : IUiAuthorizationFilter
1212 public string Pass { get ; set ; }
1313
1414 private const string AuthenticationScheme = "Basic" ;
15- private const string AuthenticationCookieName = "SerilogAuth" ;
15+ internal const string AuthenticationCookieName = "SerilogAuth" ;
1616
1717 public bool Authorize ( HttpContext httpContext )
1818 {
@@ -25,7 +25,7 @@ public bool Authorize(HttpContext httpContext)
2525 if ( ! string . IsNullOrWhiteSpace ( authCookie ) )
2626 {
2727 var hashedCredentials = EncryptCredentials ( User , Pass ) ;
28- isAuthenticated = string . Equals ( authCookie , hashedCredentials , StringComparison . OrdinalIgnoreCase ) ;
28+ isAuthenticated = authCookie . Equals ( hashedCredentials , StringComparison . OrdinalIgnoreCase ) ;
2929 }
3030 }
3131 else
@@ -53,9 +53,9 @@ public bool Authorize(HttpContext httpContext)
5353 return isAuthenticated ;
5454 }
5555
56- public string EncryptCredentials ( string user , string pass )
56+ private string EncryptCredentials ( string user , string pass )
5757 {
58- var sha256 = SHA256 . Create ( ) ;
58+ using var sha256 = SHA256 . Create ( ) ;
5959 var hashBytes = sha256 . ComputeHash ( Encoding . UTF8 . GetBytes ( $ "{ user } :{ pass } ") ) ;
6060 var hashedCredentials = BitConverter . ToString ( hashBytes ) . Replace ( "-" , "" ) . ToLower ( ) ;
6161 return hashedCredentials ;
@@ -81,7 +81,7 @@ private bool CredentialsMatch((string Username, string Password) tokens)
8181 private void SetChallengeResponse ( HttpContext httpContext )
8282 {
8383 httpContext . Response . StatusCode = 401 ;
84- httpContext . Response . Headers . Append ( "WWW-Authenticate" , "Basic realm=\" SeriLog Ui \" " ) ;
84+ httpContext . Response . Headers . Append ( "WWW-Authenticate" , "Basic realm=\" Serilog UI \" " ) ;
8585 httpContext . Response . WriteAsync ( "Authentication is required." ) ;
8686 }
8787}
0 commit comments