Skip to content
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

Feature: server add Ldap user authentication #1392

Merged
merged 1 commit into from
Aug 15, 2023

Conversation

Pan-YuJie
Copy link
Contributor

Fixes #809

Changes proposed in this pull request:

Hippo4j 接入Ldap指导

application.properties 配置文件中 , 配置下面相关信息:

image-20230720215648026

此配置文件示例在同目录下的 ldap-back.properties

# Ldap Config
spring.ldap.urls=ldap://127.0.0.1:389
spring.ldap.base=dc=xxx,dc=com
spring.ldap.embedded.credential.username=cn=xxxx,dc=xxx,dc=com
spring.ldap.embedded.credential.password=password
# Ldap Entry object-class
spring.ldap.object-class=person
# Ldap account-attribute CommonName
spring.ldap.account-attribute=cn

参数解释:

  1. spring.ldap.urls ---> Ldap服务器ip:端口

  2. spring.ldap.base ---> Ldap域名

image-20230720213802199

  1. spring.ldap.embedded.credential.username: ---> login dn

image-20230720213936217

  1. spring.ldap.embedded.credential.password ---> login dn password

  2. spring.ldap.object-class ---> Ldap Entry object-class

image-20230720213727922

  1. spring.ldap.account-attribute ---> Ldap account-attribute (cn / uid / username / ...)

image-20230720213649299


实现细节

  1. 通过读取 application.properties 配置 Ldap服务器 相关信息
  2. 使用 spring-boot-starter-data-ldap 包下的 LdapTemplate 与 Ldap服务器交互
  3. 用户 发送请求到 Ldap的登录接口 /auth/ldap/login
  4. 如果用户是第一次登录成功 , 那么会读取Ldap服务器中的信息 ,并在数据库中创建 一个相同用户名、密码为空、权限为ROLE_USER 的用户 , 并颁发Token进行后续请求
  5. 不是第一次登录用户,那么直接走 Ldap 的 密码效验步骤 ,通过后颁发Token

@magestacks magestacks merged commit de703cf into opengoofy:develop Aug 15, 2023
3 checks passed
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.

对接 LDAP 权限认证
2 participants