Skip to content

Commit

Permalink
Merge pull request #9804 from touhidurabir/i9789_main
Browse files Browse the repository at this point in the history
#9789 sensitive config data handle
  • Loading branch information
touhidurabir authored Mar 21, 2024
2 parents b1ae240 + d6e5d1f commit fd0bd36
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
28 changes: 28 additions & 0 deletions classes/config/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,34 @@

class Config
{
/**
* The sensitive data from the config files in the formate of `section` to `keys` mapping as
* [
* 'section1' => ['key1', 'key2', ...],
* 'section2' => ['key1', 'key2', ...],
* ]
*/
public const SENSITIVE_DATA = [
'database' => [
'password',
],
'email' => [
'smtp_password',
],
];

/**
* Check and determine if the given section key is sensitive data or not
*/
public static function isSensitive(string $section, string $key): bool
{
if (!isset(static::SENSITIVE_DATA[$section])) {
return false;
}

return in_array($key, static::SENSITIVE_DATA[$section]);
}

/**
* Retrieve a specified configuration variable.
*
Expand Down
2 changes: 1 addition & 1 deletion templates/admin/systemInfo.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
{foreach from=$settings item="value" key="name"}
<tr>
<td>{$name|escape}</td>
{if $name === "password"}
{if \PKP\config\Config::isSensitive($category, $name)}
<td>**************</td>
{else}
<td>{$value|escape}</td>
Expand Down

0 comments on commit fd0bd36

Please sign in to comment.