Guest mode. You can read posts without signing up. Comments, ratings, job contacts and your own posts open after you sign up and accept the rules. What is Kommit →

Редакция КоммитРедакция портала
commit 19380f4 · 10 days ago
Project

ad-tools-core: one core for 15 Active Directory services — LDAP, login, sessions, and Kerberos without dependencies

🌐 Machine-translated from Russian. Show original

ad-tools-core — the common core of the AD Tools series services (directory, organizational structure, password reset, LAPS, negotiators, and others). The code for connecting to Active Directory, logins, sessions, limits, logs, and notifications lives in one place and is broken down into services by the sync.mjsscript. A bug only needs to be fixed once.

🔒 Since 17.11.2026, the source code of the AD Tools series is provided upon request: leave a request. The showcase of the series is github.com/WorkTime-kz/ad-tools.

Link
🧩ad-tools-core — source code and documentation
🧪Test bench — ad-testlab
📦Installation of the entire series — ad-tools-suite

In this part:

Why#

The series grew to 15 services, each with its own ldap.js, auth.js, session.js , and limiter.js. The document docs/MIGRATION.md analyzed that there were two generations of implementations: the first (phonebook, ad-absence, ad-audit, ad-birthdays, ad-certs, ad-helpdesk, ad-inventory, ad-orgchart, ad-polls, ad-rooms, ad-portal) allowed ldap:// without encryption; in the second (ad-sspr, ad-laps, ad-access, ad-onboarding) — mandatory TLS 1.2+, directory class, and server sessions with CSRF. The kernel takes the best of both and closes the identified issues.

The most notable of these is logging in under someone else's account through a trusted domain. In the forest with trust relationships, OTHER\ivanov went through bind as a user of someone else's domain, and then searched sAMAccountName=ivanov found their ivanov. In the core, ДОМЕН\логин is accepted only if the domain matches LDAP_NETBIOS_DOMAIN, and логин@чужой-суффикс is searched only on userPrincipalName.

What's inside#

  • 🔌 LDAP: multiple controllers with fail-to-access transition, only LDAPS or StartTLS with certificate verification (TLS 1.2+, your own CA), page-by-page search, escape via RFC 4515 and 4514, SID, GUID and FILETIME, nested groups (LDAP_MATCHING_RULE_IN_CHAIN), and tokenGroups. ldap:// without StartTLS — denial, can only be explicitly allowed.
  • 🔑 Password login: ivanov, ivanov@corp.local , or CORP\ivanov; clear messages via AD codes (password expired, account blocked, etc.).
  • 🎫 Login via Kerberos ("built-in Windows authentication", SPNEGO) — no external dependencies, only node:crypto: ticket verification with key from keytab, the login form remains a fallback path. The second option is Kerberos on a reverse proxy (IIS or Apache) with header source verification.
  • 🍪 Sessions: signed HMAC cookies with secret rotation, revocation, and inactivity timeout or session timeout; CSRF by Origin/Sec-Fetch-Site and session token.
  • 🚦 Login attempt limit with login normalization.
  • 📝 A journal with levels, text or json format, and secret disguises.
  • ✉️ Notifications: SMTP (STARTTLS, TLS 465, AUTH PLAIN/LOGIN) and Telegram bot with a single interface notify({ to, subject, text, html }).
  • ⚙️ Settings: .env with type checking and <ИМЯ>_FILE for secrets.
  • 🛠️ Keytab utility: bin/keytab.mjs list displays keytab contents without keys create assembles keytabs from a password.

Requirements: Node.js 20.12+. No dependencies: ldapts is taken from node_modules service — all services in the series already use it. No external requests, CDN, or telemetry.

How services connect the kernel#

The kernel is not published in npm: files are copied to src/core/ each service.

node ../ad-tools-core/sync.mjs ../phonebook          # записать src/core/
node ../ad-tools-core/sync.mjs ../phonebook --check  # проверить, код 1 при расхождении
  • Each file receives the heading "File from ad-tools-core v1.0.0 (sha256:...). Do not edit manually," next to src/core/.core-manifest.json.
  • sync.mjs does not erase manually edited files and service files without kernel headers ( --forceneeded), deletes files removed from the kernel, and can unpack part of the kernel: --only kerberos/,log.js.
  • --check convenient to set in the service CI: the build will crash if the kernel copy differs from the reference.

Currently, src/core/ with kernel manifest v1.0.0 is available in all 15 services in the series.

Kerberos: what is tested and what is not#

Kerberos ticket verification is cryptography, and its errors are dangerous, so docs/KERBEROS.md has a section with honest evaluation.

Status: tested on Samba AD 4.x with MIT client for AES256, AES128, and RC4-HMAC; not tested on Windows Server AD and with Edge and Chrome browsers.

  • Primitives were compared with published vectors: n-fold (RFC 3961), string-to-key AES128/AES256 (RFC 3962), AES-CTS, MD4 (RFC 1320), NT-hash, RC4 — all matched bytewise.
  • The logic of checks (time, repetition, service name, scope, name substitution, channel binding) is on the test KDC inside the tests. It does not prove compatibility with the real KDC, and the documentation explicitly states this.
  • The real KDC — a separate workflow in GitHub Actions raises the ad-testlab stand (Samba 4.19.5, domain LAB.TEST), the ticket goes to MIT kinit and kvno, the SPNEGO token builds curl --negotiate, the kernel verifies it, curl checks the kernel response (mutual authentication), then LDAP finds the user and nested group. In the run from 14.11.2026, all five encryption scenarios passed; repeat, someone else's key, corrupted token, and foreign domain were rejected.

Not verified: Microsoft KDC, Windows SSPI clients (Edge, Chrome, Firefox on Windows, large real domain PAC), channel binding with the real client, HTTPS path, and multiple service instances. Therefore, Kerberos is only explicitly enabled in the service (KERBEROS_ENABLED=true), and the login form remains a fallback path. Kernel PAC is not verified.

How to launch#

The kernel is a library; it does not run separately. Check it and see how it works:

# после получения доступа (репозиторий закрыт, запрос — github.com/WorkTime-kz/ad-tools):
git clone https://github.com/WorkTime-kz/ad-tools-core.git
cd ad-tools-core
npm test                                     # 48 тестов node --test
node bin/keytab.mjs list путь/к/файлу.keytab   # содержимое keytab без ключей

The README includes an example server with three login methods (password, Kerberos, trusted proxy) and a table of all environment variables. The docs/KERBEROS.md includes SPN and keytab (setspn, ktpass), GPO for Edge, Chrome, and Firefox, a variant with IIS or Apache, and diagnostics.

Project status#

  • GPL-3.0-only license; source code is available upon request.
  • 48 tests node --test, all passed: RFC VECTORS, AP-REQ on test KDC, SPNEGO over HTTP, LDAP on fake directory (switching between DC, groups, foreign domain), sessions, CSRF, limits, .env, SMTP on fake server (including STARTTLS downgrading and header injection), Telegram, sync.mjs.
  • Kerberos has been tested on Samba AD, not yet on Windows Server AD. That's the main thing you need help with.

How to help#

  • 🧪 Have a test domain on Windows Server? Enable Kerberos in one docs/KERBEROS.md service and tell if you ran Edge or Chrome without a password.
  • 🔍 Take a fresh look src/kerberos/ the cryptography review is especially valuable.
  • ⭐ Star the ad-tools showcase; questions and access requests — through the Issues showcase; after gaining access, send issues and pull requests to the repository.

AD Tools Series#

Service projects: ad-testlab: a real domain controller in Docker to test AD services not on mocs.

Services on this core:

  • ad-portal — start page
  • ad-phonebook — telephone directory
  • ad-birthdays — birthdays and anniversaries
  • ad-absence — absence calendar
  • ad-polls — polls and voting
  • ad-certs — certificate expiration dates
  • ad-orgchart — organizational structure
  • ad-rooms — meeting rooms
  • ad-helpdesk — IT requests
  • ad-inventory — equipment accounting
  • ad-onboarding — hiring and firing
  • ad-sspr — password reset
  • ad-laps — local administrator passwords
  • ad-access — access requests
  • ad-audit — AD security audit
  • ad-toolkit-lite — a set of PowerShell scripts

All services are described in the github.com/WorkTime-kz/ad-tools series showcase.

👉 Repository: source code — upon request, leave a request. Series showcase — github.com/WorkTime-kz/ad-tools

Looking for:тестировщики с Windows Server ADпроверка SSO в Edge и Chromeревью криптографии Kerberosконтрибьюторы
Comments 00 участников · 0 гостей🔒 Rate and discuss after signing up

Comments · 0

No comments yet.Sign in to comment, rate and see all comments.