Skip to content

feat(ldap-auth): use lua-resty-ldap instead of lualdap#7590

Merged
spacewander merged 6 commits into
apache:masterfrom
kingluo:use-lua-resty-ldap
Aug 4, 2022
Merged

feat(ldap-auth): use lua-resty-ldap instead of lualdap#7590
spacewander merged 6 commits into
apache:masterfrom
kingluo:use-lua-resty-ldap

Conversation

@kingluo

@kingluo kingluo commented Aug 2, 2022

Copy link
Copy Markdown
Contributor

Description

Use lua-resty-ldap to do nonblocking ldap auth.

Checklist

  • I have explained the need for this PR and the problem it solves
  • I have explained the changes or the new features added to this PR
  • I have added tests corresponding to this change
  • I have updated the documentation to reflect this change
  • I have verified that this change is backward compatible (If not, please discuss on the APISIX mailing list first)

@kingluo
kingluo force-pushed the use-lua-resty-ldap branch from 054b6e9 to 52b4ee9 Compare August 2, 2022 07:15
Comment thread apisix/plugins/ldap-auth.lua Outdated
properties = {
base_dn = { type = "string" },
ldap_uri = { type = "string" },
ldap_host = { type = "string" },

Copy link
Copy Markdown
Member

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,

Copy link
Copy Markdown
Member

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

@kingluo kingluo Aug 2, 2022

Copy link
Copy Markdown
Contributor Author

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.

Comment thread 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)

Copy link
Copy Markdown
Member

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:

core.log.warn("JWT token invalid: ", jwt_obj.reason)

and it would be better to add a prefix in the error message

Comment thread apisix/plugins/ldap-auth.lua
tzssangglass
tzssangglass previously approved these changes Aug 3, 2022
Comment thread 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)

Copy link
Copy Markdown
Member

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

Comment thread docs/en/latest/plugins/ldap-auth.md Outdated
| 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. |

Copy link
Copy Markdown
Member

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?

Comment thread docs/en/latest/plugins/ldap-auth.md Outdated
| 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. |

Copy link
Copy Markdown
Member

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.

@spacewander
spacewander merged commit 0c90081 into apache:master Aug 4, 2022
Liu-Junlin pushed a commit to Liu-Junlin/apisix that referenced this pull request Nov 4, 2022
@AlinsRan AlinsRan mentioned this pull request Dec 16, 2024
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants