Skip to content

Commit

Permalink
优化日志记录对敏感信息进行加密 (#41)
Browse files Browse the repository at this point in the history
Co-authored-by: zhongshaofa <shaofa.zhong@happy-seed.com>
  • Loading branch information
zhongshaofa and zhongshaofa committed Aug 15, 2020
1 parent 1e6efb0 commit 27c7c0c
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions app/admin/middleware/SystemLog.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@
class SystemLog
{

/**
* 敏感信息字段,日志记录时需要加密
* @var array
*/
protected $sensitiveParams = [
'password',
'password_again',
];

public function handle($request, \Closure $next)
{
if ($request->isAjax()) {
Expand All @@ -34,6 +43,9 @@ public function handle($request, \Closure $next)
if (isset($params['s'])) {
unset($params['s']);
}
foreach ($params as $key => $val) {
in_array($key, $this->sensitiveParams) && $params[$key] = password($val);
}
$data = [
'admin_id' => session('admin.id'),
'url' => $url,
Expand Down

0 comments on commit 27c7c0c

Please sign in to comment.