forked from mybb/mybb
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Add Illuminate\Config\Repository, load old config values * Add internal password algorithm recognition using Illuminate\Hashing * add PHPDoc for dynamically accessed objects * Create basic Config service provider
- Loading branch information
1 parent
7ba541a
commit d225830
Showing
14 changed files
with
201 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
namespace MyBB\Config; | ||
|
||
use Illuminate\Config\Repository; | ||
|
||
class ServiceProvider extends \Illuminate\Support\ServiceProvider | ||
{ | ||
public function register() | ||
{ | ||
$this->app->singleton('config', function () { | ||
return new Repository(); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
namespace MyBB\Hashing; | ||
|
||
use Illuminate\Support\Str; | ||
|
||
class HashManager extends \Illuminate\Hashing\HashManager | ||
{ | ||
/** | ||
* Create an instance of the Mybb hash Driver. | ||
* | ||
* @return \MyBB\Hashing\MybbHasher | ||
*/ | ||
public function createMybbDriver(): MybbHasher | ||
{ | ||
return new MybbHasher(); | ||
} | ||
|
||
/** | ||
* Returns whether a driver of given name exists. | ||
* | ||
* @param string $name | ||
* @return bool | ||
*/ | ||
public function driverExists(string $name): bool | ||
{ | ||
return ( | ||
isset($this->customCreators[$name]) || | ||
method_exists($this, 'create' . Str::studly($name) . 'Driver') | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
|
||
namespace MyBB\Hashing; | ||
|
||
use Illuminate\Hashing\AbstractHasher as AbstractHasher; | ||
use Illuminate\Contracts\Hashing\Hasher as HasherContract; | ||
|
||
class MybbHasher extends AbstractHasher implements HasherContract | ||
{ | ||
/** | ||
* Indicates whether to perform an algorithm check. | ||
* | ||
* @var bool | ||
*/ | ||
protected $verifyAlgorithm = false; | ||
|
||
/** | ||
* Hash the given value. | ||
* | ||
* @param string $value | ||
* @param array $options | ||
* @return string | ||
*/ | ||
public function make($value, array $options = []) | ||
{ | ||
$salt = $options['salt'] ?? null; | ||
|
||
$hash = md5(md5($salt) . md5($value)); | ||
|
||
return $hash; | ||
} | ||
|
||
/** | ||
* Check the given plain value against a hash. | ||
* | ||
* @param string $value | ||
* @param string $hashedValue | ||
* @param array $options | ||
* @return bool | ||
*/ | ||
public function check($value, $hashedValue, array $options = []) | ||
{ | ||
$hashedUserString = self::make($value, $options); | ||
|
||
return hash_equals($hashedValue, $hashedUserString); | ||
} | ||
|
||
/** | ||
* Check if the given hash has been hashed using the given options. | ||
* | ||
* @param string $hashedValue | ||
* @param array $options | ||
* @return bool | ||
*/ | ||
public function needsRehash($hashedValue, array $options = []) | ||
{ | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
namespace MyBB\Hashing; | ||
|
||
class ServiceProvider extends \Illuminate\Hashing\HashServiceProvider | ||
{ | ||
public function register() | ||
{ | ||
$this->app->singleton('hash', function ($app) { | ||
return new HashManager($app); | ||
}); | ||
|
||
$this->app->singleton('hash.driver', function ($app) { | ||
return $app['hash']->driver(); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
namespace MyBB\Hashing; | ||
|
||
use Illuminate\Contracts\Hashing\Hasher; | ||
|
||
interface WrappableHasher extends Hasher | ||
{ | ||
/** | ||
* Hash the given value. | ||
* | ||
* @param string $hash | ||
* @return array | ||
*/ | ||
public function wrap(string $hash): string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters