File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace ProcessMaker \Events ;
4+
5+ use Illuminate \Foundation \Events \Dispatchable ;
6+ use ProcessMaker \Contracts \SecurityLogEventInterface ;
7+
8+ class UnauthorizedAccessAttempt implements SecurityLogEventInterface
9+ {
10+ use Dispatchable;
11+
12+ private array $ data ;
13+
14+ /**
15+ * Create a new event instance.
16+ *
17+ */
18+ public function __construct ()
19+ {
20+ $ this ->data = [
21+ 'url ' => [
22+ 'link ' => url ()->current (),
23+ 'label ' => url ()->current ()
24+ ]
25+ ];
26+ }
27+
28+ public function getChanges (): array
29+ {
30+ return [];
31+ }
32+
33+ public function getData (): array
34+ {
35+ return $ this ->data ;
36+ }
37+
38+ public function getEventName (): string
39+ {
40+ return 'UnauthorizedAccessAttempt ' ;
41+ }
42+ }
Original file line number Diff line number Diff line change 99use Illuminate \Routing \Route ;
1010use Illuminate \Support \Arr ;
1111use Illuminate \Support \Facades \App ;
12+ use Illuminate \Support \Facades \Auth ;
1213use Illuminate \Support \Facades \Route as RouteFacade ;
14+ use ProcessMaker \Events \UnauthorizedAccessAttempt ;
1315use Symfony \Component \HttpKernel \Exception \NotFoundHttpException ;
1416use Throwable ;
1517
@@ -47,6 +49,11 @@ public function report(Throwable $exception)
4749 echo $ exception ->getFile () . ': Line: ' . $ exception ->getLine () . "\n" ;
4850 echo $ exception ;
4951 }
52+ if ($ exception instanceof \Illuminate \Auth \Access \AuthorizationException) {
53+ try {
54+ UnauthorizedAccessAttempt::dispatch ();
55+ } catch (\Exception $ e ){}
56+ }
5057 parent ::report ($ exception );
5158 }
5259
Original file line number Diff line number Diff line change @@ -36,6 +36,9 @@ class EventServiceProvider extends ServiceProvider
3636 'ProcessMaker\Events\SettingsUpdated ' => [
3737 'ProcessMaker\Listeners\SecurityLogger ' ,
3838 ],
39+ 'ProcessMaker\Events\UnauthorizedAccessAttempt ' => [
40+ 'ProcessMaker\Listeners\SecurityLogger ' ,
41+ ],
3942 ];
4043
4144 /**
You can’t perform that action at this time.
0 commit comments