拯救 openLDAP 的上古管理界面,我写了一个现代化的 ldap 管理后台 go-ldap-admin

2022-05-18 21:00:26 +08:00
 eryajf

Go-Ldap-Admin

基于 Go+Vue 实现的 openLDAP 后台管理项目。

目录

缘起

我曾经经历的公司强依赖 openLDAP 来作为企业内部员工管理的平台,并通过 openLDAP 进行各平台的认证打通工作。

但成也萧何败也萧何,给运维省力的同时,ldap 又是维护不够友好的。

godap项目中,作者这样描述对 ldap 的感受:

The short version of the story goes like this: I hate LDAP. I used to love it. But I loved it for all the wrong reasons. LDAP is supported as an authentication solution by many different pieces of software. Aside from its de jure standard status, its wide deployment cements it as a de facto standard as well.

However, just because it is a standard doesn't mean it is a great idea.

I'll admit that given its age LDAP has had a good run. I'm sure its authors carefully considered how to construct the protocol and chose ASN.1 and its encoding with all of wellest of well meaning intentions.

The trouble is that with today's Internet, LDAP is just a pain in the ass. You can't call it from your browser. It's not human readable or easy to debug. Tooling is often arcane and confusing. It's way more complicated than what is needed for most simple authentication-only uses. (Yes, I know there are many other uses than authentication - but it's often too complicated for those too.)

Likely owing to the complexity of the protocol, there seems to be virtually no easy to use library to implement the server side of the LDAP protocol that isn't tied in with some complete directory server system; and certainly not in a language as easy to "make it work" as Go.

他说他对 ldap 又爱又恨,因为 ldap 出现的最早,许多的三方软件都兼容支持它,它成了这方面的一个标准。但问题在于,它对于维护者而言,又是复杂麻烦的。就算是有 Phpldapadmin 这样的平台能够在浏览器维护,但看到那样上古的界面,以及复杂的交互逻辑,仍旧能够把不少人劝退。

鉴于此,我开发了这个现代化的 openLDAP 管理后台。

在线体验

admin / 123456

演示地址:http://demo-go-ldap-admin.eryajf.net

项目地址

分类 GitHub Gitee
后端 https://github.com/eryajf-world/go-ldap-admin.git https://gitee.com/eryajf-world/go-ldap-admin.git
前端 https://github.com/eryajf-world/go-ldap-admin-ui.git https://gitee.com/eryajf-world/go-ldap-admin-ui.git

核心功能

快速开始

你可以通过 docker-compose 在本地快速拉起进行体验。

快速拉起的容器包括:MySQL-5.7 ,openLDAP-1.4.0 ,phpldapadmin-0.9.0 ,go-ldap-admin 。

服务端口映射如下:

Service Port
MySQL 3307:3306
openLDAP 389:389
phpldapadmin 8091:80
go-ldap-admin 8090:80,8888:8888

拉起之前确认是否有与本地端口冲突的情况。

$ git clone https://github.com/eryajf-world/go-ldap-admin.git

$ cd docs/docker-compose

$ docker-compose up -d

当看到容器都正常运行之后,可以在本地访问: http://localhost:8090 ,用户名 /密码:admin/123456

登录页:

首页:

用户管理:

分组管理:

分组内成员管理:

本地开发

前言准备

前提是已准备好 MySQL 与 openLDAP ,本地开发建议直接通过 docker 拉起即可,可参考文档:https://wiki.eryajf.net/pages/3a0d5f

拉取代码

# 后端代码
$ git clone https://github.com/eryajf-world/go-ldap-admin.git

# 前端代码
$ git clone https://github.com/eryajf-world/go-ldap-admin-ui.git

后端目录结构:

├─config     # viper 读取配置
├─controller # controller 层,响应路由请求的方法
├─docs       # 一些物料信息
├─logic      # 主要的处理逻辑
├─middleware # 中间件
├─model      # 结构体模型
├─public     # 一些公共的,工具类的放在这里
├─routes     # 所有路由
├─service    # 整合与底层存储交互的方法
├─svc        # 定义入参出参的结构体
└─test       # 跑测试用的

更改配置

# 修改后端配置
$ cd go-ldap-admin
# 文件路径 config.yml
$ vim config.yml

# 根据自己本地的情况,调整数据库以及 openLDAP 的配置信息。

启动服务

# 启动后端
$ cd go-ldap-admin
$ go mod tidy
$ go run main.go
$ make run

# 启动前端
$ cd go-ldap-admin-ui
$ yarn
$ yarn dev

本地访问: http://localhost:8090 ,用户名 /密码:admin/密码是配置文件中 openLDAP 中 admin 的密码。

生产部署

生产环境单独部署,通过 Nginx 代理服务,配置如下:

server {
    listen 80;
    server_name go-ldap-admin.eryajf.net;

    root /data/www/web/dist;

    location / {
        try_files $uri $uri/ /index.html;
        add_header Cache-Control 'no-store';
    }

    location /api/ {
        proxy_set_header Host $http_host;
        proxy_set_header  X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_pass http://127.0.0.1:8888;
    }
}

感谢

感谢如下优秀的项目,没有这些项目,不可能会有 go-ldap-admin:

另外

2644 次点击
所在节点    Linux
12 条回复
putaozhenhaochi
2022-05-18 21:14:33 +08:00
前两天还在搜现代一点的 ladp admin UI 。
👍👍
eryajf
2022-05-18 21:33:35 +08:00
@putaozhenhaochi 刚做出来,还有很多不足需要完善,欢迎持续关注,也欢迎一起共同建设
wsseo
2022-05-18 23:36:43 +08:00
关注
dandycheung
2022-05-19 01:19:22 +08:00
你做了我好久以来想花时间去做的事,赞!
eryajf
2022-05-19 07:45:02 +08:00
@wsseo 感谢关注
eryajf
2022-05-19 07:45:52 +08:00
@dandycheung 感谢支持,看来我们拥有共同的想法,恰巧我最近赋闲,就立马做了这个项目
liuxu
2022-05-19 09:13:33 +08:00
@Livid Go 编程语言
xderam
2022-05-19 10:16:39 +08:00
做的不错,得肯定下。但是,提点个人的建议:感觉还是一个 CURD 的系统,缺少一些灵魂和对于 LDAP 在生产中的理解。
例如:
1 LDAP 大多是第三方系统去对接,很少有像 CURD 那样人去操作的场景。即使有,也是系统级别的,并不是普通的增删改查。
2 LDAP 在实际使用中,to 员工的最大需求是改密码和改一些个人可以修改的信息。说白了是一些限定范围内的自助操作。
3 LDAP 的组的概念可以参考下 AD 域,并不是简单的把人员放进去。还有很多动态组 通信组的概念。但是这就牵涉到 LDAP 人员属性和组之间的联动了。需要对每个组的概念搞清楚才能设计出对应的系统的。
4 最后就是一些真的企业属性了,比如公司并购人员部门的合并管理,外包人员管理等真正企业级的需求。

练手还是很不错的,但如果真的想去做一款拯救级别的,可能还需要继续打磨和经验的积累。上古界面能到现在,甚至还有一些 C/S 的 LDAP 管理端。是因为这种普通管理的需求并不旺盛,toB 场景下还能忍。而真正的企业需求已经被微软做完了。剩下的就是 LDAP 的规划和使用了。这个就不是简单的上古管理界面的问题了。
eryajf
2022-05-19 10:48:30 +08:00
@liuxu 是的
eryajf
2022-05-19 10:54:38 +08:00
@xderam 一语中的,我也逐条回应下。表面来看的确就是一个 crud 的整合。
1 ,对接系统,与 ldap 自身管理目前在我理解是两块儿内容,这个后台还是更多针对于维护人员而言的。
2 ,这些功能其实已经集成了,用户可以通过新旧密码更改,也可以通过邮箱改密码(后台自动生成新密码发送到邮箱)。至于用户信息的变更,是给到了管理员,普通用户无法变更自己的其他信息。
3 ,这块儿的确我遇到的场景还没涉及到,所以考虑还不是很多,需要后边有人补充详细场景,转化为需求,才能落地到平台上。
4 ,这些场景的确会在现实中存在,我也还在考虑如何更好地支持。

最后,感谢肯定,感谢建议!
xderam
2022-05-19 11:30:21 +08:00
@eryajf 2 除了邮箱 还可以做成 webhook 和 im 或者短信去对接。因为好多邮箱密码认证都是连着 LDAP 的。所以很容易出现改密码 邮箱进不去的情况。
eryajf
2022-05-19 11:55:04 +08:00
@xderam 这是个好主意,因为企业用的 qq 邮箱,没有对接到 ldap ,你提的这个点的确需要注意。
不过目前接短信不是很现实,webhook 的话将消息发给个人又需要企业后台授权,所以实现上会有一些问题。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/853794

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX