[PR #5637] [MERGED] feat: ldap skip tls verify #5941

Closed
opened 2026-11-02 04:05:12 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/5637
Author: @NikanZeyaei
Created: 6/28/2026
Status: ✅ Merged
Merged: 6/28/2026
Merged by: @MHSanaei

Base: main ← Head: feature/ldap-skip-tls-verify


📝 Commits (6)

  • c04b078 feat(ldap): add InsecureSkipVerify field and tlsConfig helper
  • 55f695a feat(settings): add LdapInsecureSkipVerify setting
  • d5db896 feat(ui): add Skip TLS verification switch in LDAP settings
  • f6b413c chore(i18n): add Skip TLS verification strings to all locales
  • 49c94b7 chore(codegen): regenerate frontend artifacts
  • b0fa7a4 Merge branch 'main' into feature/ldap-skip-tls-verify

📊 Changes

28 files changed (+180 additions, -67 deletions)

View changed files

📝 frontend/public/openapi.json (+8 -0)
📝 frontend/src/generated/examples.ts (+2 -0)
📝 frontend/src/generated/schemas.ts (+8 -0)
📝 frontend/src/generated/types.ts (+2 -0)
📝 frontend/src/generated/zod.ts (+2 -0)
📝 frontend/src/models/setting.ts (+1 -0)
📝 frontend/src/pages/settings/GeneralTab.tsx (+11 -0)
📝 frontend/src/schemas/setting.ts (+1 -0)
➕ frontend/src/test/setting-ldap-skip-verify.test.ts (+20 -0)
📝 internal/util/ldap/ldap.go (+18 -17)
➕ internal/util/ldap/ldap_test.go (+22 -0)
📝 internal/web/entity/entity.go (+12 -11)
📝 internal/web/job/ldap_sync_job.go (+12 -11)
📝 internal/web/service/panel/user.go (+10 -8)
📝 internal/web/service/setting.go (+25 -20)
📝 internal/web/translation/ar-EG.json (+2 -0)
📝 internal/web/translation/en-US.json (+2 -0)
📝 internal/web/translation/es-ES.json (+2 -0)
📝 internal/web/translation/fa-IR.json (+2 -0)
📝 internal/web/translation/id-ID.json (+2 -0)

...and 8 more files

📄 Description

Summary

Adds an optional ldapInsecureSkipVerify setting that, when enabled, establishes LDAPS connections without validating the server certificate chain (tls.Config.InsecureSkipVerify: true). Disabled by default; clearly marked as insecure in the UI.

Why

Closes https://github.com/MHSanaei/3x-ui/issues/5538

LDAP sync and login currently fail with x509: certificate signed by unknown authority against enterprise directory servers (e.g. Microsoft AD CS) that use an internal CA which cannot be imported into the panel's system trust store. This PR gives operators an escape hatch for those environments while keeping secure verification on by default.

The setting is wired into both the sync job (FetchVlessFlags) and the LDAP login path (AuthenticateUser). The original issue's file list missed the login path, which would have left an inconsistent state where sync worked but login still failed against an untrusted CA.

Type of change

  • Bug fix
  • New feature
  • Refactoring (no behavior change)
  • Documentation
  • Tests only
  • Build / CI / tooling
  • Other

Areas affected

  • Frontend (UI / panel pages)
  • Backend (API endpoints, login, settings)
  • Xray config generation
  • Subscription (share links / Clash / JSON)
  • Statistics / traffic counters
  • Database / migrations
  • Install / upgrade script
  • Docker image
  • Multi-node (sub-nodes)
  • Telegram bot

How was this tested?

Automated:

  • go test ./... — full suite green; new TestTLSConfig_InsecureSkipVerifyPropagates pins that Config.InsecureSkipVerify flows through the extracted tlsConfig helper to tls.Config.InsecureSkipVerify (catches future regressions where someone re-hardcodes false).
  • cd frontend && npm run test — all 41 test files pass, including the new setting-ldap-skip-verify Vitest that round-trips ldapInsecureSkipVerify through the Zod schema and the AllSetting model.
  • npm run typecheck, npm run lint, npm run build — all clean.
  • npm run gen + git diff --exit-code -- frontend/src/generated frontend/public/openapi.json — clean (codegen CI gate).

Manual QA performed by reviewer (recommended before merge):

  1. Build — go build ./... and cd frontend && npm run typecheck && npm run lint && npm run test && npm run build.
  2. Codegen clean — cd frontend && npm run gen && git diff --exit-code -- frontend/src/generated frontend/public/openapi.json (must be clean after commit).
  3. Regression (default off) — point LDAP at an LDAPS server with a public-trusted cert, leave the new checkbox off → sync + login succeed (no behavior change vs. main).
  4. Feature on — point LDAP at a server with an internal-CA cert, tick "Skip TLS certificate verification" → sync (LDAP sync job started … Fetched N LDAP flags) and LDAP login now succeed where they previously failed with x509: certificate signed by unknown authority.
  5. UX guard — with "Use TLS (LDAPS)" off, confirm the new switch is disabled (greyed out).
  6. Persistence — save settings, restart panel, confirm the checkbox retains its state (DB round-trip via UpdateAllSetting reflect loop).

Screenshots / recordings

N/A — purely a settings UI addition (one new Switch under "Use TLS (LDAPS)" with an insecure-warning description). The visible behavior is self-evident from the field label and description.

Breaking changes

None.

  • The new key defaults to "false" everywhere (default map, model, UI switch, Zod schema, generated artifacts), so existing deployments are unaffected — zero-config behavior change.
  • No DB migration needed — settings are key/value rows; the new key materializes on first read via defaultValueMap.
  • The crypto/tls import in internal/util/ldap/ldap.go stays (used by the new tlsConfig helper). No import additions or removals at the call sites.
  • The InsecureSkipVerify: true mode disables all cert validation (hostname + chain). The skipTlsVerifyDesc text says so explicitly, and an alternative "trust a custom CA via tls.Config.RootCAs" is intentionally out of scope — the issue explicitly requests the skip-verify escape hatch.

Checklist

  • I tested the change locally and confirmed the described behavior.
  • I added or updated tests for the new behavior (when applicable).
  • go build ./... and the test suite pass locally.
  • For frontend changes: npm run lint, npm run typecheck, and npm run build pass.
  • [] I updated the Wiki / README / API docs if user-facing behavior changed. (N/A — no user-facing docs to update; the field is self-describing via its in-UI description)
  • My commits follow the project's existing message style.
  • I have no unrelated changes mixed into this PR.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/MHSanaei/3x-ui/pull/5637 **Author:** [@NikanZeyaei](https://github.com/NikanZeyaei) **Created:** 6/28/2026 **Status:** ✅ Merged **Merged:** 6/28/2026 **Merged by:** [@MHSanaei](https://github.com/MHSanaei) **Base:** `main` ← **Head:** `feature/ldap-skip-tls-verify` --- ### 📝 Commits (6) - [`c04b078`](https://github.com/MHSanaei/3x-ui/commit/c04b078009c044e7ec3b6ea4d5de017e99fed07d) feat(ldap): add InsecureSkipVerify field and tlsConfig helper - [`55f695a`](https://github.com/MHSanaei/3x-ui/commit/55f695a811929e27081b67e3aa346f4054ea7a7f) feat(settings): add LdapInsecureSkipVerify setting - [`d5db896`](https://github.com/MHSanaei/3x-ui/commit/d5db89695d805a711c02668995a3a8552f5f8499) feat(ui): add Skip TLS verification switch in LDAP settings - [`f6b413c`](https://github.com/MHSanaei/3x-ui/commit/f6b413ccf475775585615b0398483d90b0aa82bb) chore(i18n): add Skip TLS verification strings to all locales - [`49c94b7`](https://github.com/MHSanaei/3x-ui/commit/49c94b7fe6a0f931685ec53afb0096d0f3cff15f) chore(codegen): regenerate frontend artifacts - [`b0fa7a4`](https://github.com/MHSanaei/3x-ui/commit/b0fa7a4a392b98ab5b2923733fcf09274aafac29) Merge branch 'main' into feature/ldap-skip-tls-verify ### 📊 Changes **28 files changed** (+180 additions, -67 deletions) <details> <summary>View changed files</summary> 📝 `frontend/public/openapi.json` (+8 -0) 📝 `frontend/src/generated/examples.ts` (+2 -0) 📝 `frontend/src/generated/schemas.ts` (+8 -0) 📝 `frontend/src/generated/types.ts` (+2 -0) 📝 `frontend/src/generated/zod.ts` (+2 -0) 📝 `frontend/src/models/setting.ts` (+1 -0) 📝 `frontend/src/pages/settings/GeneralTab.tsx` (+11 -0) 📝 `frontend/src/schemas/setting.ts` (+1 -0) ➕ `frontend/src/test/setting-ldap-skip-verify.test.ts` (+20 -0) 📝 `internal/util/ldap/ldap.go` (+18 -17) ➕ `internal/util/ldap/ldap_test.go` (+22 -0) 📝 `internal/web/entity/entity.go` (+12 -11) 📝 `internal/web/job/ldap_sync_job.go` (+12 -11) 📝 `internal/web/service/panel/user.go` (+10 -8) 📝 `internal/web/service/setting.go` (+25 -20) 📝 `internal/web/translation/ar-EG.json` (+2 -0) 📝 `internal/web/translation/en-US.json` (+2 -0) 📝 `internal/web/translation/es-ES.json` (+2 -0) 📝 `internal/web/translation/fa-IR.json` (+2 -0) 📝 `internal/web/translation/id-ID.json` (+2 -0) _...and 8 more files_ </details> ### 📄 Description ## Summary Adds an optional `ldapInsecureSkipVerify` setting that, when enabled, establishes LDAPS connections without validating the server certificate chain (`tls.Config.InsecureSkipVerify: true`). Disabled by default; clearly marked as insecure in the UI. ## Why Closes https://github.com/MHSanaei/3x-ui/issues/5538 LDAP sync and login currently fail with `x509: certificate signed by unknown authority` against enterprise directory servers (e.g. Microsoft AD CS) that use an internal CA which cannot be imported into the panel's system trust store. This PR gives operators an escape hatch for those environments while keeping secure verification on by default. The setting is wired into **both** the sync job (`FetchVlessFlags`) and the LDAP login path (`AuthenticateUser`). The original issue's file list missed the login path, which would have left an inconsistent state where sync worked but login still failed against an untrusted CA. ## Type of change - [ ] Bug fix - [x] New feature - [ ] Refactoring (no behavior change) - [ ] Documentation - [ ] Tests only - [ ] Build / CI / tooling - [ ] Other ## Areas affected - [x] Frontend (UI / panel pages) - [x] Backend (API endpoints, login, settings) - [ ] Xray config generation - [ ] Subscription (share links / Clash / JSON) - [ ] Statistics / traffic counters - [ ] Database / migrations - [ ] Install / upgrade script - [ ] Docker image - [ ] Multi-node (sub-nodes) - [ ] Telegram bot ## How was this tested? Automated: - `go test ./...` — full suite green; new `TestTLSConfig_InsecureSkipVerifyPropagates` pins that `Config.InsecureSkipVerify` flows through the extracted `tlsConfig` helper to `tls.Config.InsecureSkipVerify` (catches future regressions where someone re-hardcodes `false`). - `cd frontend && npm run test` — all 41 test files pass, including the new `setting-ldap-skip-verify` Vitest that round-trips `ldapInsecureSkipVerify` through the Zod schema and the `AllSetting` model. - `npm run typecheck`, `npm run lint`, `npm run build` — all clean. - `npm run gen` + `git diff --exit-code -- frontend/src/generated frontend/public/openapi.json` — clean (codegen CI gate). Manual QA performed by reviewer (recommended before merge): 1. **Build** — `go build ./...` and `cd frontend && npm run typecheck && npm run lint && npm run test && npm run build`. 2. **Codegen clean** — `cd frontend && npm run gen && git diff --exit-code -- frontend/src/generated frontend/public/openapi.json` (must be clean after commit). 3. **Regression (default off)** — point LDAP at an LDAPS server with a public-trusted cert, leave the new checkbox off → sync + login succeed (no behavior change vs. main). 4. **Feature on** — point LDAP at a server with an **internal-CA** cert, tick "Skip TLS certificate verification" → sync (`LDAP sync job started` … `Fetched N LDAP flags`) and LDAP login now succeed where they previously failed with `x509: certificate signed by unknown authority`. 5. **UX guard** — with "Use TLS (LDAPS)" off, confirm the new switch is disabled (greyed out). 6. **Persistence** — save settings, restart panel, confirm the checkbox retains its state (DB round-trip via `UpdateAllSetting` reflect loop). ## Screenshots / recordings N/A — purely a settings UI addition (one new Switch under "Use TLS (LDAPS)" with an insecure-warning description). The visible behavior is self-evident from the field label and description. ## Breaking changes None. - The new key defaults to `"false"` everywhere (default map, model, UI switch, Zod schema, generated artifacts), so existing deployments are unaffected — zero-config behavior change. - No DB migration needed — settings are key/value rows; the new key materializes on first read via `defaultValueMap`. - The `crypto/tls` import in `internal/util/ldap/ldap.go` stays (used by the new `tlsConfig` helper). No import additions or removals at the call sites. - The `InsecureSkipVerify: true` mode disables **all** cert validation (hostname + chain). The `skipTlsVerifyDesc` text says so explicitly, and an alternative "trust a custom CA via `tls.Config.RootCAs`" is intentionally out of scope — the issue explicitly requests the skip-verify escape hatch. ## Checklist - [x] I tested the change locally and confirmed the described behavior. - [x] I added or updated tests for the new behavior (when applicable). - [x] `go build ./...` and the test suite pass locally. - [x] For frontend changes: `npm run lint`, `npm run typecheck`, and `npm run build` pass. - [] I updated the Wiki / README / API docs if user-facing behavior changed. _(N/A — no user-facing docs to update; the field is self-describing via its in-UI description)_ - [x] My commits follow the project's existing message style. - [x] I have no unrelated changes mixed into this PR. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 04:05:12 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MHSanaei/3x-ui#5941
No description provided.