allow injecting CsrfTokenManager by class

Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
Robin Appelman 2019-07-08 17:44:55 +02:00 committed by Roeland Jago Douma
parent 6cfe29b0e0
commit 5cb00aba09
No known key found for this signature in database
GPG key ID: F941078878347C0C

View file

@ -1018,7 +1018,7 @@ class Server extends ServerContainer implements IServerContainer {
$request
);
});
$this->registerService('CsrfTokenManager', function (Server $c) {
$this->registerService(CsrfTokenManager::class, function (Server $c) {
$tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom());
return new CsrfTokenManager(
@ -1026,6 +1026,7 @@ class Server extends ServerContainer implements IServerContainer {
$c->query(SessionStorage::class)
);
});
$this->registerAlias('CsrfTokenManager', CsrfTokenManager::class);
$this->registerService(SessionStorage::class, function (Server $c) {
return new SessionStorage($c->getSession());
});
@ -1901,7 +1902,7 @@ class Server extends ServerContainer implements IServerContainer {
* @return CsrfTokenManager
*/
public function getCsrfTokenManager() {
return $this->query('CsrfTokenManager');
return $this->query(CsrfTokenManager::class);
}
/**