If anyone find it useful, I'have crafted a simple code for wp-config.php (or any other app) since we needed ot on OLS mainly.
I did array for passwords, so you can have more than one and we are ignoring user, because we don't care for that.
$http_pass = [ "your_secure_password" ];
if( isset( $_SERVER[ 'PHP_AUTH_PW' ] ) && in_array( $_SERVER['PHP_AUTH_PW'], $http_pass, true ) ) {} else { header('HTTP/1.1 401 Unauthorized'); header( 'WWW-Authenticate: Basic realm="Protected Area"' ); exit; }
here is "not minified" version
// set your password
$http_pass = [ "your_secure_password" ];
// check for passwords with strict param
if( isset( $_SERVER[ 'PHP_AUTH_PW' ] ) && in_array( $_SERVER['PHP_AUTH_PW'], $http_pass, true ) ) {
// user is authenticated
} else {
header('HTTP/1.1 401 Unauthorized');
header( 'WWW-Authenticate: Basic realm="Protected Area"' );
exit;
}