The idea is:
Protect system integration in product deployment is critical for enterprise security. We need support Managed Identity instead of using plan key text.
As using key is a risk for attack. Following is an example for eliminate using key , instead we just using managed identity in Azure OpenAI GPT instance with DefaultAzureCredential(). This will reduce attack and improve quality and security.
we need n8n to support this as a model how to care client’s system protection. Azure OpenAI with AAD Auth — AutoGen
from autogen_ext.models import AzureOpenAIChatCompletionClient
from azure.identity import DefaultAzureCredential, get_bearer_token_provider
Create the token provider
token_provider = get_bearer_token_provider(
DefaultAzureCredential(), “https://cognitiveservices.azure.com/.default”
)
client = AzureOpenAIChatCompletionClient(
azure_deployment=“{your-azure-deployment}”,
model=“{model-name, such as gpt-4o}”,
api_version=“2024-02-01”,
azure_endpoint=“https://{your-custom-endpoint}.openai.azure.com/”,
azure_ad_token_provider=token_provider,
)
My use case:
I think it would be beneficial to add this because:
Consider billions of account and key are hacked and stollen every year which cause of hundreds of billons of lost and damage, eliminate plan text key is critical. This is a requirements for any enterprise system and services for higher bar of protection.
Any resources to support this?
Are you willing to work on this?
Following is the fix:
import { DefaultAzureCredential, getBearerTokenProvider } from “@azure/identity”;
import { AzureOpenAI } from “openai”;
import “dotenv/config.js”;
const credential = new DefaultAzureCredential();
const scope = “https://cognitiveservices.azure.com/.default”;
const azureADTokenProvider = getBearerTokenProvider(credential, scope);
// You will need to set these environment variables or edit the following values
const endpoint = “https://.openai.azure.com/”;
const apiVersion = “2024-05-01-preview”;
const deployment = “gpt-4o”; // This must match your deployment name
const AZURE_OPENAI_ENDPOINT = process.env[“AZURE_OPENAI_ENDPOINT”] || endpoint;
const AZURE_OPENAI_VERSION = process.env[“AZURE_OPENAI_VERSION”] || apiVersion;
const AZURE_OPENAI_DEPLOYMENT = process.env[“AZURE_OPENAI_DEPLOYMENT”] || deployment;
const MODEL = process.env[“model”] || “gpt-4o”;
console.log("==endpoint: “,AZURE_OPENAI_ENDPOINT);
console.log(”==version: “,AZURE_OPENAI_VERSION);
console.log(”==deploy: “,AZURE_OPENAI_DEPLOYMENT);
console.log(”==model: ",MODEL);
export async function main_llm() {
const options = { azureADTokenProvider:azureADTokenProvider, deployment: AZURE_OPENAI_DEPLOYMENT,apiVersion: AZURE_OPENAI_VERSION ,endpoint: AZURE_OPENAI_ENDPOINT};
const client = new AzureOpenAI(options);
return client;
}