Repository navigation
feat(engine): loginBasicAuth flag for LOGIN_TOKEN logins - #1460
Conversation
… login request (HelpCode-ai#982) LOGIN_TOKEN logins that take Basic credentials (Wazuh POST /security/user/authenticate) set loginBasicAuth: true. The engine builds Authorization: Basic base64(username:password) for the login call only; the password is not offered to body templates and no body is sent without loginBody. An Authorization in loginHeaders is refused (as are signedJwt, bcrypt passwordHashing and a username with ':') rather than silently overridden. Failed login errors are scrubbed of the header and the encoded credentials. validate-adapters (rule login-basic-auth) and catalog.spec check the same.
helpcodeai
left a comment
There was a problem hiding this comment.
Thanks @GallaGit, this is what we agreed in #982, and the code reads well. The engine builds the header itself, the conflicting configurations are refused before any request, and outbound-http.ts already drops Authorization on a cross-origin redirect.
One CI failure, and it comes from the docs change: docs/tool-definition.md and docs/connectors/login-token-auth.md feed llms-full.txt, so the backend job stops at node scripts/generate-llms-txt.mjs --check with "llms-full.txt is stale". Lint, typecheck and Jest have not run in CI yet because of that.
The branch is also behind main. Please merge main, then run:
node scripts/generate-llms-txt.mjsand commit the regenerated llms-full.txt. Once the checks are green I'll merge it.
A follow-up PR for the connector edit page, so it keeps loginBasicAuth and loginHeaders, is welcome. After that, the Wazuh adapter.
|
FYI: the Wazuh adapter that uses this flag is up as a draft in #1461, stacked on this branch. I'll rebase it onto main and mark it ready once this one merges. |
helpcodeai
left a comment
There was a problem hiding this comment.
Thanks, this looks good. The Basic header is built only from the username and password, it never goes through templates, conflicting settings are refused, and the error is cleaned before it travels on.
One thing blocks the merge: the backend CI fails at "Verify generated AI documentation is up to date", because docs/tool-definition.md changed. Please run node scripts/generate-llms-txt.mjs from the repository root, commit the regenerated files, and merge the latest main into the branch. Then I'll merge it.
The edit page dropping loginBasicAuth is fine as a follow-up.
|
I merged the latest main into your branch and committed the regenerated llms-full.txt myself, so you don't need to push anything for this. I'll merge once CI is green. |
helpcodeai
left a comment
There was a problem hiding this comment.
Thanks @GallaGit. Checked again after the regenerated docs: the Basic header is built only from the username and password, conflicting settings are refused before any request, and the credentials are scrubbed from errors. CI is green, merging.
Adds an opt-in
loginBasicAuth: trueflag to the LOGIN_TOKEN login config, as agreed in #982. When set, the engine sendsAuthorization: Basic base64(username:password)on the login request only. The credentials never go through templates (${password}resolves empty), and no body is sent unlessloginBodyis defined.Validation (engine,
validate-adaptersrulelogin-basic-auth,catalog.spec)AuthorizationinloginHeaderstogether with the flag is rejected before any request, so there's never doubt about which credentials the provider gets.signedJwtor bcryptpasswordHashing, a username containing:, a missingusername/passwordparam, and${password}inloginBody.Secrets handling: on login failure the error is sanitised (message, config and response headers,
request._header) and keeps the status. Debug logs mask the credentials.Docs:
docs/tool-definition.mdanddocs/connectors/login-token-auth.md.Tests
login-token.service.spec: 71/71, 7 new tests.validate-adapters.test.mjs: 32/32.tscand eslint: clean.Known gap (out of scope): the connector edit page (
connectors/[id]/page.tsx) rebuildsauthConfigwithout advanced fields, so editing would droploginBasicAuth, the same way it already dropsloginHeaders. Happy to fix that in a follow-up.The Wazuh adapter (#982) will follow on top of this.