Add some authorization to the infrastructure code.

This commit is contained in:
Dave Smith-Hayes 2024-05-14 21:44:08 -04:00
parent 54473bdf79
commit 0518a44d3f
3 changed files with 36 additions and 0 deletions

View File

@ -23,4 +23,9 @@ class DatabaseConnection implements DatabaseConnectionInterface
{ {
return $this->pdo; return $this->pdo;
} }
public function getName(): string
{
return $this->name;
}
} }

View File

@ -0,0 +1,22 @@
<?php
namespace Slovocast\Infrastructure\User;
use Slovocast\Infrastructure\User\UserAuthorizationInterface;
/**
* This empty class will essentially just check hashed passwords passed
* into it using the default `password_` functions from PHP.
*/
class BasicUserAuthorization implements UserAuthorizationInterface
{
public function hash(string $password): string
{
return password_hash($password, PASSWORD_BCRYPT);
}
public function verify(string $password, string $hash): bool
{
return password_verify($password, $hash);
}
}

View File

@ -0,0 +1,9 @@
<?php
namespace Slovocast\Infrastructure\User;
interface UserAuthorizationInterface
{
public function hash(string $password): string;
public function verify(string $password, string $hash): bool;
}