Skip to content

feat(Node Elasticsearch): update authentication to support API Key and Basic Auth - #207

Open
everettbu wants to merge 10 commits into
masterfrom
elasticsearch_api_auth
Open

feat(Node Elasticsearch): update authentication to support API Key and Basic Auth#207
everettbu wants to merge 10 commits into
masterfrom
elasticsearch_api_auth

Conversation

@everettbu

Copy link
Copy Markdown

Mirror of n8n-io/n8n#21405
Original author: justincastilla


Summary

Adds API Key authentication support to the Elasticsearch node, enabling modern authentication for Elastic Cloud, Elastic Serverless, as well as self-hosted Elastic instances.

  • Added "API Key" authentication type (now the default for new credentials)
  • Maintained "Basic Auth" for backwards compatibility with existing workflows
  • Updated credential test endpoint from /_xpack to / for Serverless compatibility
  • Fixed baseURL template string handling to properly remove trailing slashes
  • Enhanced authenticate() method to preserve existing request headers
  • Added unit tests covering both authentication methods

Testing

  • Created 5 unit tests for credential authentication
    • API Key authentication header generation
    • Basic Auth credential handling
    • Preservation of existing request headers
    • Both authentication methods validated independently

Updated UI

API Key Authentication Option:
Screenshot 2025-10-30 at 3 35 28 PM

Review / Merge checklist


Note

Adds API Key authentication (default) alongside Basic Auth, updates credential test and baseURL handling, and introduces unit tests for auth flows.

  • Credentials (credentials/ElasticsearchApi.credentials.ts):
    • Add authType with options apiKey (default) and basicAuth; introduce apiKey, username, password; keep required baseUrl.
    • Implement authenticate(...) to apply Basic Auth or Authorization: ApiKey ...; preserves existing headers; legacy fallback when authType missing; input validation with clear errors.
    • Update test request to GET / and normalize baseURL by trimming trailing slashes.
  • Types (nodes/Elastic/Elasticsearch/types.ts):
    • Extend ElasticsearchApiCredentials to include authType, apiKey, and optional username/password.
  • Tests (nodes/Elastic/Elasticsearch/tests/credentials/ElasticsearchApi.test.ts):
    • Add unit tests for API Key and Basic Auth, header preservation, backward compatibility, and validation errors.

Written by Cursor Bugbot for commit 808cccf. This will update automatically on new commits. Configure here.

@everettbu everettbu added node/improvement New feature or request community Authored by a community member in linear Issue or PR has been created in Linear for internal review labels Jan 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community Authored by a community member in linear Issue or PR has been created in Linear for internal review node/improvement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants