forked from devsam/core
feat: API에서 민감한 argument 지정
This commit is contained in:
@@ -15,6 +15,8 @@ use sammo\Validator;
|
||||
|
||||
class LoginByID extends \sammo\BaseAPI
|
||||
{
|
||||
static array $sensitiveArgs = ['password'];
|
||||
|
||||
public function validateArgs(): ?string
|
||||
{
|
||||
$v = new Validator($this->args);
|
||||
|
||||
@@ -14,6 +14,7 @@ use sammo\Validator;
|
||||
|
||||
class LoginByToken extends LoginByID
|
||||
{
|
||||
static array $sensitiveArgs = ['hashedToken'];
|
||||
|
||||
public function getRequiredSessionMode(): int
|
||||
{
|
||||
|
||||
@@ -10,6 +10,18 @@ abstract class BaseAPI
|
||||
const REQ_GAME_LOGIN = 2;
|
||||
const REQ_READ_ONLY = 4;
|
||||
|
||||
static array $sensitiveArgs = [];
|
||||
|
||||
public function getFilteredArgs(): array {
|
||||
$filteredArgs = $this->args;
|
||||
foreach (static::$sensitiveArgs as $argName) {
|
||||
if (isset($filteredArgs[$argName])) {
|
||||
$filteredArgs[$argName] = '***';
|
||||
}
|
||||
}
|
||||
return $filteredArgs;
|
||||
}
|
||||
|
||||
protected array $args;
|
||||
protected string $rootPath;
|
||||
public function __construct(string $rootPath, array $args)
|
||||
|
||||
Reference in New Issue
Block a user