-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(ldap-auth): use lua-resty-ldap instead of lualdap #7590
Conversation
054b6e9
to
52b4ee9
Compare
apisix/plugins/ldap-auth.lua
Outdated
@@ -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" }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should keep the compatibility of the configuration
verify_ldap_host = conf.verify_ldap_host, | ||
base_dn = conf.base_dn, | ||
attribute = uid, | ||
keepalive = 60000, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's doc the newly added timeout and keepalive
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@spacewander These items are not exported to admin api, we only use default values. So we need to doc the default values? But it's kind of internal parameters.
apisix/plugins/ldap-auth.lua
Outdated
} | ||
local res, err = ldap.ldap_authenticate(user.username, user.password, ldapconf) | ||
if not res then | ||
core.log.error(err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use warning level log for this situation:
apisix/apisix/plugins/jwt-auth.lua
Line 369 in 5cbcf24
core.log.warn("JWT token invalid: ", jwt_obj.reason) |
and it would be better to add a prefix in the error message
apisix/plugins/ldap-auth.lua
Outdated
} | ||
local res, err = ldap.ldap_authenticate(user.username, user.password, ldapconf) | ||
if not res then | ||
core.log.warn("ldap-auth: ", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The prefix should be more meaningful
docs/en/latest/plugins/ldap-auth.md
Outdated
@@ -49,7 +49,8 @@ For Route: | |||
|----------|---------|----------|---------|------------------------------------------------------------------------| | |||
| base_dn | string | True | | Base dn of the LDAP server. For example, `ou=users,dc=example,dc=org`. | | |||
| ldap_uri | string | True | | URI of the LDAP server. | | |||
| use_tls | boolean | False | `true` | If set to `true` uses TLS. | | |||
| use_tls | boolean | False | `false` | If set to `true` uses TLS. | | |||
| verify_ldap_host| boolean | False | `false` | Whether to verify the server certificate when `use_tls` is enabled; If set to `true`, you must set `ssl_trusted_certificate` in `config.yaml`, and make sure the host of `ldap_uri` matches the host in server certificate. | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This field doesn't have default value in the code. Why add a default value in the doc?
docs/en/latest/plugins/ldap-auth.md
Outdated
@@ -49,7 +49,8 @@ For Route: | |||
|----------|---------|----------|---------|------------------------------------------------------------------------| | |||
| base_dn | string | True | | Base dn of the LDAP server. For example, `ou=users,dc=example,dc=org`. | | |||
| ldap_uri | string | True | | URI of the LDAP server. | | |||
| use_tls | boolean | False | `true` | If set to `true` uses TLS. | | |||
| use_tls | boolean | False | `false` | If set to `true` uses TLS. | | |||
| verify_ldap_host| boolean | False | `false` | Whether to verify the server certificate when `use_tls` is enabled; If set to `true`, you must set `ssl_trusted_certificate` in `config.yaml`, and make sure the host of `ldap_uri` matches the host in server certificate. | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the description, we should name this field tls_verify
? It doesn't verify the host but the TLS relative stuff.
Description
Use lua-resty-ldap to do nonblocking ldap auth.
Checklist