Skip to content
This repository was archived by the owner on Jul 24, 2023. It is now read-only.

Commit 8cbcaf3

Browse files
committed
Added configurable logging
1 parent 7e610f5 commit 8cbcaf3

File tree

2 files changed

+36
-13
lines changed

2 files changed

+36
-13
lines changed

src/AdldapAuthServiceProvider.php

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -99,17 +99,9 @@ protected function registerListeners()
9999
if ($this->isLogging()) {
100100
// If logging is enabled, we will set up our event listeners that
101101
// log each event fired throughout the authentication process.
102-
Event::listen(Events\Importing::class, Listeners\LogImport::class);
103-
Event::listen(Events\Synchronized::class, Listeners\LogSynchronized::class);
104-
Event::listen(Events\Synchronizing::class, Listeners\LogSynchronizing::class);
105-
Event::listen(Events\Authenticated::class, Listeners\LogAuthenticated::class);
106-
Event::listen(Events\Authenticating::class, Listeners\LogAuthentication::class);
107-
Event::listen(Events\AuthenticationFailed::class, Listeners\LogAuthenticationFailure::class);
108-
Event::listen(Events\AuthenticationRejected::class, Listeners\LogAuthenticationRejection::class);
109-
Event::listen(Events\AuthenticationSuccessful::class, Listeners\LogAuthenticationSuccess::class);
110-
Event::listen(Events\DiscoveredWithCredentials::class, Listeners\LogDiscovery::class);
111-
Event::listen(Events\AuthenticatedWithWindows::class, Listeners\LogWindowsAuth::class);
112-
Event::listen(Events\AuthenticatedModelTrashed::class, Listeners\LogTrashedModel::class);
102+
foreach ($this->getLoggingEvents() as $event => $listener) {
103+
Event::listen($event, $listener);
104+
}
113105
}
114106
}
115107

@@ -152,6 +144,16 @@ protected function makeUserProvider(Hasher $hasher, array $config)
152144
*/
153145
protected function isLogging()
154146
{
155-
return Config::get('adldap_auth.logging', false);
147+
return Config::get('adldap_auth.logging.enabled', false);
148+
}
149+
150+
/**
151+
* Returns the configured authentication events to log.
152+
*
153+
* @return array
154+
*/
155+
protected function getLoggingEvents()
156+
{
157+
return Config::get('adldap_auth.logging.events', []);
156158
}
157159
}

src/Config/auth.php

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,8 +277,29 @@
277277
|
278278
| This option is useful for debugging as well as auditing.
279279
|
280+
| You can freely remove any events you would not like to log below.
281+
|
280282
*/
281283

282-
'logging' => true,
284+
'logging' => [
285+
286+
'enabled' => true,
287+
288+
'events' => [
289+
290+
\Adldap\Laravel\Events\Importing::class => \Adldap\Laravel\Listeners\LogImport::class,
291+
\Adldap\Laravel\Events\Synchronized::class => \Adldap\Laravel\Listeners\LogSynchronized::class,
292+
\Adldap\Laravel\Events\Synchronizing::class => \Adldap\Laravel\Listeners\LogSynchronizing::class,
293+
\Adldap\Laravel\Events\Authenticated::class => \Adldap\Laravel\Listeners\LogAuthenticated::class,
294+
\Adldap\Laravel\Events\Authenticating::class => \Adldap\Laravel\Listeners\LogAuthentication::class,
295+
\Adldap\Laravel\Events\AuthenticationFailed::class => \Adldap\Laravel\Listeners\LogAuthenticationFailure::class,
296+
\Adldap\Laravel\Events\AuthenticationRejected::class => \Adldap\Laravel\Listeners\LogAuthenticationRejection::class,
297+
\Adldap\Laravel\Events\AuthenticationSuccessful::class => \Adldap\Laravel\Listeners\LogAuthenticationSuccess::class,
298+
\Adldap\Laravel\Events\DiscoveredWithCredentials::class => \Adldap\Laravel\Listeners\LogDiscovery::class,
299+
\Adldap\Laravel\Events\AuthenticatedWithWindows::class => \Adldap\Laravel\Listeners\LogWindowsAuth::class,
300+
\Adldap\Laravel\Events\AuthenticatedModelTrashed::class => \Adldap\Laravel\Listeners\LogTrashedModel::class,
301+
302+
],
303+
],
283304

284305
];

0 commit comments

Comments
 (0)