Skip to content

Conversation

@KirCute
Copy link
Member

@KirCute KirCute commented Dec 3, 2025

Description / 描述

支持 WebDAV、FTP 和 SFTP 端口使用 LDAP 验证。

用户表新增列allow_ldap,只有启用时才支持该用户通过 LDAP 登录,从旧版本升级上来后默认值为true

Motivation and Context / 背景

How Has This Been Tested? / 测试

Checklist / 检查清单

  • I have read the CONTRIBUTING document.
    我已阅读 CONTRIBUTING 文档。
  • I have formatted my code with go fmt or prettier.
    我已使用 go fmtprettier 格式化提交的代码。
  • I have added appropriate labels to this PR (or mentioned needed labels in the description if lacking permissions).
    我已为此 PR 添加了适当的标签(如无权限或需要的标签不存在,请在描述中说明,管理员将后续处理)。
  • I have requested review from relevant code authors using the "Request review" feature when applicable.
    我已在适当情况下使用"Request review"功能请求相关代码作者进行审查。
  • I have updated the repository accordingly (If it’s needed).
    我已相应更新了相关仓库(若适用)。

@jyxjjj
Copy link
Member

jyxjjj commented Dec 4, 2025

其实也没有那么Breaking。。。

@KirCute
Copy link
Member Author

KirCute commented Dec 4, 2025

其实也没有那么Breaking。。。

你说得对,主要是一开始我没把allow ldap的默认值设为true,感觉有默认值以后就不breaking了

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds support for LDAP authentication across WebDAV, FTP, and SFTP protocols. The implementation refactors LDAP login logic into a common package and introduces a new allow_ldap user field to control LDAP access per user.

Key Changes:

  • Extracted LDAP authentication logic into server/common/ldap.go for reuse across multiple protocols
  • Added allow_ldap boolean field to the User model with a default value of true
  • Integrated LDAP authentication fallback in WebDAV, FTP, and SFTP authentication handlers

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
server/common/ldap.go New file containing extracted LDAP authentication logic (HandleLdapLogin, LdapRegister) and dial helper function
server/handles/ldap_login.go Refactored to use common LDAP functions; added allow_ldap permission check
server/webdav.go Introduced tryLogin helper that attempts LDAP auth if local password validation fails and user has LDAP enabled
server/ftp.go Added LDAP authentication fallback when password hash validation fails
server/sftp.go Added LDAP authentication fallback when password hash validation fails
internal/model/user.go Added AllowLdap field with default value true to control per-user LDAP access

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@KirCute
Copy link
Member Author

KirCute commented Dec 8, 2025

Copilot 说有问题的代码全部是我从server/handles/ldap_login.go直接挪过去的,,,

@jyxjjj
Copy link
Member

jyxjjj commented Dec 8, 2025

我觉得有几个还说的挺对的,比如连接没关我好像也没找到哪里关,另外比如那个cert verify也不应该直接去掉,应该改成驱动配置选项用户自己选。

@KirCute KirCute marked this pull request as draft December 8, 2025 12:11
@KirCute KirCute marked this pull request as ready for review December 8, 2025 13:07
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.

2 participants