Skip to content

Commit

Permalink
ldap: 开放更多的参数可配置
Browse files Browse the repository at this point in the history
  • Loading branch information
mylxsw committed Mar 8, 2023
1 parent b32db17 commit 465740b
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 9 deletions.
23 changes: 23 additions & 0 deletions .env.docker
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,29 @@ LDAP_PASSWORD_SYNC=true
LDAP_LOGIN_FALLBACK=true
# LDAP 信息中,用哪个字段作为用户的名称,比如 displayname, cn 等
LDAP_SYNC_NAME_ATTR=cn

# LDAP 模式,默认为 ActiveDirectory
# 如果使用的是 OpenLDAP,请修改为 Adldap\Schemas\OpenLDAP
# LDAP_SCHEMA="Adldap\Schemas\ActiveDirectory"
# LDAP_SCHEMA="Adldap\Schemas\OpenLDAP"

# 默认值为 Adldap\Laravel\Scopes\UpnScope (ActiveDirectory 模式)
# 当使用的是 OpenLDAP 时,请修改为 Adldap\Laravel\Scopes\UidScope
# LDAP_SCOPES_CLASS="Adldap\Laravel\Scopes\UidScope"
# LDAP_SCOPES_CLASS="Adldap\Laravel\Scopes\UpnScope"

# 默认为 userprincipalname,当使用 OpenLDAP 时,修改为 uid
# LDAP_LOCATE_USERS_BY=userprincipalname
# LDAP_LOCATE_USERS_BY=uid

# 默认为 distinguishedname,当使用 OpenLDAP 时,修改为 uid
# LDAP_BIND_USER_BY=distinguishedname
# LDAP_BIND_USER_BY=uid

# 默认为 userprincipalname,当使用 OpenLDAP 时,修改为 mail
# LDAP_SYNC_EMAIL_ATTR=userprincipalname
# LDAP_SYNC_EMAIL_ATTR=mail

# LDAP 限制只允许属于该成员的用户登录
WIZARD_LDAP_ONLY_MEMBER_OF=

Expand Down
23 changes: 23 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,29 @@ LDAP_PASSWORD_SYNC=true
LDAP_LOGIN_FALLBACK=true
# LDAP 信息中,用哪个字段作为用户的名称,比如 displayname, cn 等
LDAP_SYNC_NAME_ATTR=cn

# LDAP 模式,默认为 ActiveDirectory
# 如果使用的是 OpenLDAP,请修改为 Adldap\Schemas\OpenLDAP
# LDAP_SCHEMA="Adldap\Schemas\ActiveDirectory"
# LDAP_SCHEMA="Adldap\Schemas\OpenLDAP"

# 默认值为 Adldap\Laravel\Scopes\UpnScope (ActiveDirectory 模式)
# 当使用的是 OpenLDAP 时,请修改为 Adldap\Laravel\Scopes\UidScope
# LDAP_SCOPES_CLASS="Adldap\Laravel\Scopes\UidScope"
# LDAP_SCOPES_CLASS="Adldap\Laravel\Scopes\UpnScope"

# 默认为 userprincipalname,当使用 OpenLDAP 时,修改为 uid
# LDAP_LOCATE_USERS_BY=userprincipalname
# LDAP_LOCATE_USERS_BY=uid

# 默认为 distinguishedname,当使用 OpenLDAP 时,修改为 uid
# LDAP_BIND_USER_BY=distinguishedname
# LDAP_BIND_USER_BY=uid

# 默认为 userprincipalname,当使用 OpenLDAP 时,修改为 mail
# LDAP_SYNC_EMAIL_ATTR=userprincipalname
# LDAP_SYNC_EMAIL_ATTR=mail

# LDAP 限制只允许属于该成员的用户登录
WIZARD_LDAP_ONLY_MEMBER_OF=

Expand Down
12 changes: 6 additions & 6 deletions app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ public function boot()
$this->addInvitationCodeRules('invitation_code');

// 在日志中输出sql历史
// \DB::listen(function (QueryExecuted $query) {
// \Log::debug('sql_execute', [
// 'sql' => $query->sql,
// 'binds' => $query->bindings,
// ]);
// });
\DB::listen(function (QueryExecuted $query) {
\Log::debug('sql_execute', [
'sql' => $query->sql,
'binds' => $query->bindings,
]);
});
}

/**
Expand Down
6 changes: 3 additions & 3 deletions config/ldap_auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,9 @@

'ldap' => [

'locate_users_by' => 'userprincipalname',
'locate_users_by' => env('LDAP_LOCATE_USERS_BY', 'userprincipalname'),

'bind_users_by' => 'distinguishedname',
'bind_users_by' => env('LDAP_BIND_USER_BY', 'distinguishedname'),

],

Expand Down Expand Up @@ -287,7 +287,7 @@

'sync_attributes' => [

'email' => 'userprincipalname',
'email' => env('LDAP_SYNC_EMAIL_ATTR', 'userprincipalname'),

'name' => env('LDAP_SYNC_NAME_ATTR', 'cn'),

Expand Down

0 comments on commit 465740b

Please sign in to comment.