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: supports LDAP #1030

Merged
merged 3 commits into from
Mar 22, 2024
Merged

Conversation

D0n9
Copy link

@D0n9 D0n9 commented Mar 12, 2024

背景

我司在 2023 年选择使用 CodeAnalysis 作为白盒代码扫描平台,主要考虑是整体功能与需求匹配度较高,是开源的并且社区活跃度也不错,基于 Django 框架二次开发也容易上手,整体架构清晰有良好的代码风格,相关文档和运行日志也很齐全。

本次 PR 需求来自 #610

注意到近期有相同需求的用户越来越多 ,所以考虑贡献代码

实现思路

CodeAnalysis 不考虑认证源是什么,只关心是否认证成功,所以只需要在认证逻辑里添加 ldap 认证的代码就可以

  1. CodeAnalysis 使用微服务架构,先更新配置 login APP open_base.py 支持 LDAP
  2. CodeAnalysis 使用 Django 自带的权限系统,只需修改在 Login 微服务里 CodeAnalysis/server/projects/login/login/apis/v3.py OAInfoAPIView 类,把这部分 「登录认证」代码修改为先通过 LDAP 认证,如果认证通过并且获取 or 创建账号成功就生成 access_token 等认证成功参数,如果不通过就使用 CodeAnalysis 默认的登录方式。

使用方式

在使用前请先根据具体 LDAP 服务情况修改以下三个文件

  1. CodeAnalysis/scripts/config.sh
  2. CodeAnalysis/server/dockerconfs/.env.local
  3. CodeAnalysis/server/projects/login/apps/settings/open_base.py AUTH_LDAP_USER_ATTR_MAP

如果是源码部署,应该可以直接使用(未测试)
如果是 Docker/Docker compose 部署,因为 pull 镜像里代码可能还未更新,所以请在 deploy 之后再 build login-server 更新代码

问题反馈

如果遇到登录失败的情况,请先检查 LDAP 配置是否正确,如果确认配置没问题,请带上 login-server 日志提交 issues

Copy link
Collaborator

@Lingghh Lingghh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

server/dockerconfs/Dockerfile-common-mirror Outdated Show resolved Hide resolved
server/projects/login/login/apis/v3.py Outdated Show resolved Hide resolved
@zhang9w0v5 zhang9w0v5 merged commit 1f35cc5 into Tencent:dev/Support-LDAP Mar 22, 2024
@D0n9 D0n9 deleted the Support-LDAP branch March 25, 2024 07:21
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