feat: Add Kerberos/SPNEGO authentication support for repeater#751
Open
bararchy wants to merge 5 commits into
Open
feat: Add Kerberos/SPNEGO authentication support for repeater#751bararchy wants to merge 5 commits into
bararchy wants to merge 5 commits into
Conversation
Member
Author
|
Member
Author
|
Upstream PR for GSSAPI support in node-libcurl: NeuraLegion/node-libcurl#19 Once that merges and prebuilds are published, Kerberos will work end-to-end on Linux. |
bararchy
added a commit
to NeuraLegion/node-libcurl
that referenced
this pull request
May 21, 2026
Add the 'gssapi' vcpkg feature on non-Windows platforms to enable SPNEGO/Negotiate authentication. On Windows, SSPI (already included) handles Negotiate, so gssapi is skipped there. Changes: - scripts/vcpkg-setup.js: conditionally inject 'gssapi' feature into vcpkg.json on Linux/macOS (vcpkg does not support curl[gssapi] on Windows) - install-system-packages: add krb5-dev (Alpine) and libkrb5-dev (Ubuntu) so vcpkg can link curl against system GSSAPI libraries Related: NeuraLegion/bright-cli#751 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
aborovsky
requested changes
Jun 2, 2026
aborovsky
left a comment
Contributor
There was a problem hiding this comment.
Thx for new feature delivery. Pls check few comments.
aborovsky
added a commit
that referenced
this pull request
Jun 3, 2026
…Executor Exercises the actual code path changed by PR #751: HttpRequestExecutor (kerberos: true, credentials: scanner@EXAMPLE.COM:ScannerPass1) → libcurl CURLAUTH_NEGOTIATE (HTTPAUTH=4) → mit-krb5 GSSAPI handshake → Apache httpd mod_auth_gssapi (Require valid-user) → HTTP 200 Previously test.sh only validated build-time artifacts and static analysis. This new step confirms the end-to-end authentication path works at runtime.
Contributor
|
I've test full flow for Kerberos auth at HttpRequestExecutor with single test case and it seems to work. |
Add native Kerberos/SPNEGO authentication via libcurl's CURLAUTH_NEGOTIATE. This allows the repeater to authenticate with target services that require Kerberos, using either explicit credentials or system keytab/kinit tickets. New CLI options: --kerberos Enable Kerberos/SPNEGO auth --kerberos-domains Restrict Kerberos to specific domains (wildcards) --kerberos-credentials user:password format (optional) --kerberos-delegation Allow credential delegation Also configurable via REPEATER_KERBEROS* environment variables. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The connection reuse test failed in environments without GSSAPI/SPNEGO support (libcurl errors before connecting). Changed the test to verify the executor handles kerberos-enabled requests gracefully regardless of GSSAPI availability. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add krb5-dev (build-time) and krb5-libs + krb5 (runtime) to enable libcurl's GSSAPI/Negotiate authentication inside the container. - krb5-dev: needed at build-time for curl GSSAPI linkage - krb5-libs: runtime GSSAPI shared libraries - krb5: client tools (kinit, klist, kdestroy) for ticket management Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The krb5/krb5-libs packages provide: - kinit/klist/kdestroy for Kerberos ticket management - libgssapi_krb5.so runtime library NOTE: Full Kerberos support also requires @brightsec/node-libcurl to be rebuilt with the 'gssapi' vcpkg feature (upstream change needed). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…close - Replace CURLAUTH_NEGOTIATE=4 with CurlAuth.Negotiate enum - Replace CURLGSSAPI_DELEGATION_FLAG=1 with CurlGssApi.DelegationFlag (value 2) - Don't send Connection: close when Kerberos is active (breaks SPNEGO)
4e8e9a4 to
4ca1ee8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add native Kerberos/SPNEGO (Negotiate) authentication support for the repeater agent. This allows the CLI to transparently authenticate with target services protected by Kerberos, leveraging libcurl's built-in GSSAPI/SSPI support — no new npm dependencies required.
Usage
Basic — Use System Kerberos Ticket
If you already have a valid ticket (via
kinit), just enable the flag:The repeater will use the system's cached Kerberos ticket for all target domains.
Restrict to Specific Domains
Apply Kerberos only to specific hosts (supports wildcards):
Requests to other domains proceed without Kerberos authentication.
Explicit Credentials (No kinit Required)
Provide username and password directly — useful in CI/CD pipelines or containers where you can't run
kinitbeforehand:Format:
user@REALM:passwordoruser:password(libcurl will use the default realm fromkrb5.confif onlyuser:passwordis given).Credential Delegation
Allow the target server to use your credentials to access other Kerberos-protected services on your behalf (constrained delegation):
Environment Variables
All options are also available via environment variables (prefix
REPEATER_):--kerberosREPEATER_KERBEROStrue--kerberos-domainsREPEATER_KERBEROS_DOMAINS*.corp.internal *.ad.company.com--kerberos-credentialsREPEATER_KERBEROS_CREDENTIALSuser@REALM:pass--kerberos-delegationREPEATER_KERBEROS_DELEGATIONtrueFull Example (Docker / CI)
Implementation Details
Architecture
The implementation hooks into the existing
HttpRequestExecutorpipeline by adding two private methods:shouldApplyKerberos(request)— Determines whether Kerberos should be applied for a given request URL by matching against configured domains (or returningtruefor all if no domains specified).applyCurlKerberos(curl, request)— Sets the libcurl options when Kerberos applies:HTTPAUTH = 4(CURLAUTH_NEGOTIATE) — tells libcurl to use SPNEGO/NegotiateUSERPWD = credentials || ":"— empty:means "use system ticket cache"GSSAPI_DELEGATION = 1— when--kerberos-delegationis setConnection Reuse
Kerberos/SPNEGO is a multi-round-trip protocol. The initial request gets a
401withWWW-Authenticate: Negotiate, then libcurl automatically retries with the SPNEGO token. This requires TCP connection reuse, so when Kerberos is enabled:Multihandle pool is activated (same mechanism as--ntlm)TCP_KEEPALIVEandTCP_KEEPIDLEare setFRESH_CONNECT/FORBID_REUSEare not setDomain Matching
Uses the same wildcard-to-regex mechanism (
Helpers.wildcardToRegExp) as--proxy-domains, supporting patterns like*.corp.internal,host.example.com,192.168.*.Conflicts & Validation
--kerberosconflicts with--ntlm(both use HTTPAUTH, can't combine)--kerberos-domains,--kerberos-credentials,--kerberos-delegationall imply--kerberos(yargsimplies)Prerequisites
curl --versionshould showGSS-APIorSPNEGO).klistto verify) or credentials are provided.Files Changed
src/RequestExecutor/RequestExecutorOptions.tsKerberosOptionsinterfacesrc/RequestExecutor/HttpRequestExecutor.tsshouldApplyKerberos(),applyCurlKerberos(), connection reuse logicsrc/Commands/RunRepeater.tssrc/RequestExecutor/HttpRequestExecutor.spec.ts