ballerina-platform / ballerina-library

The Ballerina Library
https://ballerina.io/learn/api-docs/ballerina/
Apache License 2.0
136 stars 64 forks source link

Proposal: Add API Key Based Authentication for Ballerina Twilio Connector #7343

Closed SachinAkash01 closed 3 days ago

SachinAkash01 commented 2 weeks ago

Summary

Implement the capabilities to support API Key based authentication for the Ballerina Twilio Connector.

Goals

Motivation

In the current Ballerina Twilio connector (version 4.x.x), only Auth Token-based authentication is supported, which grants full access to the associated Twilio account. While this is sufficient for local testing or low-risk scenarios, it poses significant security challenges in production environments. Auth Tokens allow any client with access to interact with the entire Twilio account, including sensitive resources and data, exposing a risk of unauthorized access if credentials are compromised.

API Key-based authentication provides a robust alternative by enabling finer-grained control over access permissions. Twilio’s API Key authentication allows developers to issue and manage multiple keys with tailored scopes, specific to certain applications or functionalities. API Keys can be rotated, revoked, or regenerated without impacting the overall account integrity, thereby reducing downtime in the event of a compromise and allowing for quicker incident response.

By implementing API Key-based authentication in the Ballerina Twilio connector, we can offer developers a more flexible and secure mechanism for managing Twilio API interactions. This approach aligns with industry best practices, improving security posture and minimizing the risks associated with broad-scope credentials in production environments.

Description

In the current approach (Auth Token based authentication) of the Ballerina Twilio connector requires an accountSidand authToken, which grants full access to the Twilio account. To improve security and offer more granular control over access, this proposal introduces support for API Key-based authentication. API Key-based authentication allows developers to use an apiKey, apiSecret, and accountSid limiting access to specific resources and allowing for easier key management

Enhanced ConnectionConfig Structure:

@display {label: "Connection Config"}
public type ConnectionConfig record {|
    AuthTokenConfig|ApiKeyConfig auth;
    //other fields
|};
public type AuthTokenConfig record {|
    string accountSid;
    string authToken;
|};

public type ApiKeyConfig record {|
    string accountSid;
    string apiKey;
    string apiSecret;
|};

Version

No response

SachinAkash01 commented 3 days ago

Added the proposal to repo with following PR: