spacewander commented on code in PR #7590:
URL: https://github.com/apache/apisix/pull/7590#discussion_r935300873
##########
apisix/plugins/ldap-auth.lua:
##########
@@ -30,11 +30,13 @@ local schema = {
title = "work with route or service object",
properties = {
base_dn = { type = "string" },
- ldap_uri = { type = "string" },
+ ldap_host = { type = "string" },
Review Comment:
We should keep the compatibility of the configuration
##########
apisix/plugins/ldap-auth.lua:
##########
@@ -139,8 +141,20 @@ function _M.rewrite(conf, ctx)
local uid = conf.uid or "cn"
local userdn = uid .. "=" .. user.username .. "," .. conf.base_dn
- local ld = lualdap.open_simple (conf.ldap_uri, userdn, user.password,
conf.use_tls)
- if not ld then
+ local ldapconf = {
+ timeout = 10000,
+ start_tls = false,
+ ldap_host = conf.ldap_host,
+ ldap_port = conf.ldap_port,
+ ldaps = conf.use_tls,
+ verify_ldap_host = conf.verify_ldap_host,
+ base_dn = conf.base_dn,
+ attribute = uid,
+ keepalive = 60000,
Review Comment:
Let's doc the newly added timeout and keepalive
##########
apisix/plugins/ldap-auth.lua:
##########
@@ -139,8 +141,20 @@ function _M.rewrite(conf, ctx)
local uid = conf.uid or "cn"
local userdn = uid .. "=" .. user.username .. "," .. conf.base_dn
- local ld = lualdap.open_simple (conf.ldap_uri, userdn, user.password,
conf.use_tls)
- if not ld then
+ local ldapconf = {
+ timeout = 10000,
+ start_tls = false,
+ ldap_host = conf.ldap_host,
+ ldap_port = conf.ldap_port,
+ ldaps = conf.use_tls,
+ verify_ldap_host = conf.verify_ldap_host,
+ base_dn = conf.base_dn,
+ attribute = uid,
+ keepalive = 60000,
+ }
+ local res, err = ldap.ldap_authenticate(user.username, user.password,
ldapconf)
+ if not res then
+ core.log.error(err)
Review Comment:
We use warning level log for this situation:
https://github.com/apache/apisix/blob/5cbcf246021b9f5a97ce98e999a7ed65a1cbc117/apisix/plugins/jwt-auth.lua#L369
and it would be better to add a prefix in the error message
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]