Authentication overview

RudderStack's authentication mechanisms are designed to secure both the data plane and the control plane of its customer data platform. The data plane involves the flow of event data from sources (e.g., website, mobile app) through RudderStack to various destinations (e.g., data warehouses, analytics tools). The control plane manages your RudderStack workspace, including configuring sources, destinations, transformations, and accessing administrative settings. Establishing secure authentication is essential for preventing unauthorized access to your data streams and ensuring data integrity and privacy.

For data ingestion, RudderStack typically relies on unique API keys associated with specific sources. These keys identify the origin of the data and ensure it is routed correctly within your workspace. When transmitting data, RudderStack mandates the use of Transport Layer Security (TLS) 1.2 or higher for all network communications, encrypting data in transit and protecting against eavesdropping and tampering, as detailed in RudderStack's security practices. This aligns with industry standards for secure data transmission, as recommended by organizations like the Internet Engineering Task Force (IETF) for secure communication protocols.

Access to the RudderStack dashboard and its management APIs is secured through a separate set of credentials, typically involving personal access tokens or standard user authentication. These credentials grant permissions to configure your RudderStack setup, manage billing, and interact with the administrative API endpoints. Understanding the distinction between data plane and control plane authentication is crucial for implementing a robust security posture within your RudderStack deployment.

Supported authentication methods

RudderStack supports different authentication methods depending on whether you are interacting with the data plane (sending event data) or the control plane (managing your workspace via API).

Data Plane Authentication: API Keys

For sending event data from your applications or servers to RudderStack, API keys are the primary authentication method. Each source you configure in RudderStack is assigned a unique Write Key (also referred to as a Source ID in some contexts). This key identifies your source and authorizes the incoming data stream. The Write Key is included in the payload or headers of your API requests or SDK calls.

  • Client-side SDKs: When using RudderStack's client-side SDKs (e.g., JavaScript, iOS, Android), the Write Key is typically initialized with the SDK. The SDK then automatically includes it in all subsequent event calls.
  • Server-side SDKs and HTTP API: For server-side SDKs (e.g., Node.js, Python, Go) or direct HTTP API calls, the Write Key must be explicitly provided in your requests, either in the request body (for /v1/batch and /v1/track endpoints) or as part of the URL parameters, as specified in the RudderStack API reference.

Control Plane Authentication: Personal Access Tokens

To interact with the RudderStack control plane API, which allows programmatic management of your workspace (e.g., creating sources, configuring destinations, managing transformations), Personal Access Tokens (PATs) are used. PATs are long-lived tokens generated from your RudderStack dashboard and are associated with your user account's permissions. They provide a secure way to automate administrative tasks without exposing your main login credentials.

  • Dashboard access: Your primary login credentials (email and password, often secured with Two-Factor Authentication) are used to access the RudderStack dashboard.
  • Control Plane API: PATs are sent in the Authorization header of your HTTP requests to the control plane API, usually in the format Bearer <YOUR_PERSONAL_ACCESS_TOKEN>.

The following table summarizes RudderStack's authentication methods:

Method When to Use Security Level
API Key (Write Key) Sending event data to RudderStack (Data Plane) from sources like websites, mobile apps, or backend services. Moderate (requires secure handling; typically exposed client-side for web/mobile)
Personal Access Token (PAT) Programmatic access to the RudderStack Control Plane API for managing configurations, sources, and destinations. High (should be treated as sensitive credentials; never exposed client-side)
User Login (Email/Password) Accessing the RudderStack dashboard for manual configuration and management. High (often protected by 2FA)

Getting your credentials

To obtain the necessary authentication credentials for RudderStack, you will primarily use the RudderStack dashboard.

Obtaining a Write Key (API Key)

  1. Log in to the RudderStack Dashboard: Access your RudderStack account via the RudderStack application login.
  2. Navigate to Sources: From the left navigation pane, select 'Sources'.
  3. Select or Create a Source: Choose an existing source or click 'Add Source' to create a new one. When creating a source, select the platform (e.g., JavaScript, iOS, HTTP API).
  4. Retrieve the Write Key: After creating or selecting a source, the Write Key (Source ID) will be displayed prominently on the source's overview page. Copy this key for use in your SDKs or API calls. RudderStack provides detailed instructions for setting up JavaScript sources, for example, which includes using this key.

Generating a Personal Access Token (PAT)

  1. Log in to the RudderStack Dashboard: Access your RudderStack account.
  2. Navigate to Settings: Click on your profile icon or name in the top right corner and select 'Settings'.
  3. Go to Personal Access Tokens: In the settings menu, find and select 'Personal Access Tokens'.
  4. Generate New Token: Click 'Generate New Token', provide a descriptive name for the token (e.g., 'CI/CD Integration Token'), and set an expiration date if desired.
  5. Copy the Token: The generated PAT will be displayed once. It is crucial to copy this token immediately as it will not be shown again. Store it securely in your environment variables or a secrets manager.

Authenticated request example

Here are examples demonstrating how to authenticate requests using RudderStack's primary methods.

Example 1: Sending an event with a Write Key (Data Plane - Node.js SDK)

This example demonstrates how to initialize the RudderStack Node.js SDK and send a track event using a Write Key. The Write Key is passed during the SDK initialization.


const Rudderstack = require('@rudderstack/rudder-sdk-node');

const rudderstack = new Rudderstack(
  'YOUR_RUDDERSTACK_WRITE_KEY', // Replace with your actual Write Key
  {
    dataPlaneUrl: 'https://hosted.rudderlabs.com' // Replace with your data plane URL
  }
);

rudderstack.track({
  userId: 'user-123',
  event: 'Product Viewed',
  properties: {
    productId: '507f1f77bcf86cd799439011',
    productName: 'Example Widget',
    category: 'Electronics'
  }
}, (err, response) => {
  if (err) {
    console.error('Error sending event:', err);
  } else {
    console.log('Event sent successfully:', response.status);
  }
});

In this Node.js example, YOUR_RUDDERSTACK_WRITE_KEY is the API key obtained from your RudderStack source configuration. The SDK handles embedding this key securely in the outgoing requests.

Example 2: Making a Control Plane API call with a Personal Access Token (curl)

This example shows how to use a Personal Access Token to fetch a list of all sources configured in your RudderStack workspace via the Control Plane API.


curl -X GET \
  https://api.rudderstack.com/v2/sources \
  -H 'Authorization: Bearer YOUR_PERSONAL_ACCESS_TOKEN' \
  -H 'Content-Type: application/json'

Here, YOUR_PERSONAL_ACCESS_TOKEN is the PAT you generated in the RudderStack dashboard. It is included in the Authorization header with the Bearer scheme, which is a common practice for OAuth 2.0 and similar token-based authentication systems, as outlined by OAuth 2.0 Bearer Token Usage specifications.

Security best practices

Implementing strong security practices for your RudderStack authentication credentials is vital for protecting your customer data pipelines. Adhering to these guidelines helps prevent unauthorized access and maintains data integrity.

  • Protect your API Keys (Write Keys):
    • Client-side vs. Server-side: While Write Keys are typically exposed in client-side applications (web browsers, mobile apps) for data collection, treat them with care. Do not use a Write Key for server-side operations that require higher security.
    • Domain Restrictions: For web sources, configure domain restrictions in the RudderStack dashboard to ensure events are only accepted from your approved domains. This reduces the risk of malicious actors attempting to send data using your Write Key from unauthorized origins.
    • Rotation: Regularly rotate your Write Keys, especially if you suspect a compromise or as part of a routine security policy. RudderStack allows you to generate new keys and revoke old ones.
  • Secure Personal Access Tokens (PATs):
    • Treat as Passwords: PATs grant significant control over your RudderStack workspace. Treat them with the same level of security as you would your root passwords.
    • Environment Variables: Never hardcode PATs directly into your code. Instead, store them in environment variables, a secure secrets manager (e.g., AWS Secrets Manager, HashiCorp Vault), or a secure configuration file that is not committed to version control.
    • Least Privilege: When generating PATs, ensure they have only the minimum necessary permissions required for the task they perform. For example, a token used for deploying transformations might only need access to transformation-related APIs.
    • Expiration Dates: Set expiration dates for PATs whenever possible. This limits the window of exposure if a token is compromised.
    • Audit and Revoke: Regularly audit the PATs configured in your workspace. Revoke any tokens that are no longer in use or if their purpose has been fulfilled.
  • Enable Two-Factor Authentication (2FA):
    • Always enable 2FA for your RudderStack dashboard login. This adds an extra layer of security, requiring a second verification method (e.g., a code from a mobile authenticator app) in addition to your password, significantly reducing the risk of unauthorized access even if your password is stolen.
  • Monitor API Usage:
    • Regularly review your RudderStack usage logs and audit trails, if available, to detect any unusual activity or unauthorized API calls.
  • Use Secure Communication:
    • Always ensure that all communication with RudderStack's APIs (both data plane and control plane) occurs over HTTPS with TLS 1.2 or higher. RudderStack enforces this by default, but it's important to verify your client-side configurations.