silverstripe / auditor
为 SilverStripe 添加安全审计跟踪。
3.2.0-beta1
2024-08-07 04:50 UTC
Requires
- php: ^8.1
- monolog/monolog: ^3.2
- psr/log: ^3
- silverstripe/framework: ^5
- tractorcow/silverstripe-proxy-db: ^2
Requires (Dev)
- 4.x-dev
- 3.x-dev
- 3.2.x-dev
- 3.2.0-beta1
- 3.1.x-dev
- 3.1.2
- 3.1.1
- 3.1.0
- 3.1.0-rc1
- 3.1.0-beta1
- 3.0.x-dev
- 3.0.4
- 3.0.3
- 3.0.2
- 3.0.1
- 3.0.0
- 3.0.0-rc1
- 3.0.0-beta1
- 2.x-dev
- 2.6.x-dev
- 2.6.3
- 2.6.2
- 2.6.1
- 2.6.0
- 2.6.0-rc1
- 2.6.0-beta1
- 2.5.x-dev
- 2.5.0
- 2.4.x-dev
- 2.4.0
- 2.3.x-dev
- 2.3.0
- 2.3.0-rc1
- 2.3.0-beta1
- 2.2.x-dev
- 2.2.1
- 2.2.0
- 2.1.x-dev
- 2.1.5
- 2.1.4
- 2.1.3
- 2.1.2
- 2.1.1
- 2.1.0
- 2.0.x-dev
- 2.0.0
- 2.0.0-beta2
- 2.0.0-beta1
- 1.x-dev / 1.2.x-dev
- 1.1.x-dev
- 1.1.0
- 1.0.x-dev
- 1.0.2
- 1.0.1
- 1.0
- dev-master
This package is auto-updated.
Last update: 2024-09-19 01:45:34 UTC
README
Auditor 模块将一系列扩展钩子安装到框架中,以监控认证用户的活动。审计跟踪通过 Monolog 写入到 LOG_AUTH
系统日志设施中,并包括
- 登录尝试(成功和失败)
- 注销
- 可能影响实时站点的页面操作
- 与安全相关的更改,例如成员被添加到组或权限更改。
安装
composer require silverstripe/auditor
自定义审计跟踪
您可以通过访问 AuditLogger
来将您自己的日志添加到审计跟踪中,这通过注入器最简单
use SilverStripe\CMS\Controllers\ContentController; class MyPageController extends ContentController { private static $dependencies = [ 'auditLogger' => '%$AuditLogger' ]; }
AuditLogger 保证实现 PSR-3 LoggerInterface,可以以多个级别记录事件,带有任意上下文
public function dostuff() { $this->auditLogger->info('stuff happened'); // You can also pass an arbitrary context array which will be included in the log. $this->auditLogger->warn('stuff happened', ['defcon' => 'amber']); }
以下是在您的开发机器上的审计日志中会出现的内容(确切格式取决于您的操作系统)
Aug 24 11:09:02 SilverStripe_audit[80615]: stuff happened [] {"real_ip":"127.0.0.1","url":"/do-stuff/","http_method":"GET","server":"localhost","referrer":null}
Aug 24 11:09:02 SilverStripe_audit[80615]: stuff happened {"defcon":"amber"} {"real_ip":"127.0.0.1","url":"/do-stuff/","http_method":"GET","server":"localhost","referrer":null}
故障排除
我们使用动态生成的类来捕获数据库操作事件。此类被缓存,在某些情况下可能会保留旧的、错误的类版本。您可以删除它,具体方法是删除缓存,特别是名为 <ss-cache-dir>/<user>/.cache.CLC.SearchManipulateCapture_SilverStripeORMConnectMySQLDatabase
的文件。
贡献
提交 pull-request 最有可能修复错误或添加功能。