Skip to content

Commit 091f2fa

Browse files
authored
Merge pull request #536 from dbarzin/dev
add group match
2 parents 639cf73 + 072fb25 commit 091f2fa

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

.env.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ LDAP_TLS=false
7272
# OpenLDAP: uid, cn, mail ; AD: sAMAccountName, userPrincipalName, mail
7373
LDAP_LOGIN_ATTRIBUTES="uid,cn,mail,sAMAccountName,userPrincipalName"
7474

75+
# Match user group or null for any group
76+
LDAP_GROUP=
77+
7578
##################################################
7679
# Socialite
7780
##################################################

app/Http/Controllers/Auth/LoginController.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ protected function ldapBindAndGetUser(string $appUsername, string $password): ?L
4848
$query->in($base);
4949
}
5050

51+
// Optionel : resteindre à un group si configuré
52+
$group = trim((string) config('app.ldap_group'));
53+
if ($group !== '') {
54+
$query->where('memberOf', $group);
55+
}
56+
5157
// Attributs de login à tester côté LDAP (uid, sAMAccountName, etc.)
5258
$attrs = array_values(array_filter(array_map('trim', explode(',', (string) config('app.ldap_login_attributes')))));
5359
if (empty($attrs)) {

config/app.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@
149149
'ldap_auto_provision' => (bool) env('LDAP_AUTO_PROVISION', false),
150150
'ldap_login_attributes' => env('LDAP_LOGIN_ATTRIBUTES', 'uid,cn,mail,sAMAccountName,userPrincipalName'),
151151
'ldap_users_base_dn' => env('LDAP_USERS_BASE_DN'),
152+
'ldap_group' => env('LDAP_GROUP'),
152153

153154
/*
154155
|--------------------------------------------------------------------------

0 commit comments

Comments
 (0)