Add identity-based auth to your Semantic Kernel plugins
Replace API keys with cryptographic identities in your Microsoft Semantic Kernel plugins. Zero credential management, automatic key rotation, zero trust architecture. Drop-in replacement for existing authentication patterns.
API keys in Semantic Kernel plugins create security debt
Every plugin that calls external services needs authentication. API keys in environment variables, secrets managers, or hardcoded configuration create attack surface. Key rotation requires downtime. Leaked keys require emergency replacement across all instances.
xLink eliminates credentials entirely. Each plugin gets a cryptographic identity (DID). Authentication happens via signed messages, not stored secrets. Keys are ephemeral and rotate automatically. Zero trust by default.
Install via NuGet or pip
.NET (C#)
dotnet add package PrivateMe.SemanticKernel.xLink
Python
pip install private-me-semantic-kernel-xlink
5-Minute Setup Guide
dotnet add package PrivateMe.SemanticKernel.xLink
using PrivateMe.SemanticKernel.xLink; var identity = await PluginIdentity.CreateAsync("PaymentPlugin"); // Identity stored securely, no credentials needed
var kernel = Kernel.CreateBuilder() .AddOpenAIChatCompletion("gpt-4", apiKey) .Build(); // Wrap plugin with xLink authentication var plugin = new PaymentPlugin(); var authenticatedPlugin = await xLinkPlugin.WrapAsync(plugin, identity); kernel.Plugins.AddFromObject(authenticatedPlugin, "Payments");
// Existing plugin calls work unchanged var result = await kernel.InvokeAsync( "Payments", "ProcessPayment", new { amount = 100.00, currency = "USD" } ); // xLink handles authentication automatically // No API keys, no manual auth headers
// Register trusted plugins for capability-based access var registry = new TrustRegistry(); await registry.RegisterAsync(identity, new[] { "payments:process", "payments:refund" }); // Automatic capability checks on every invocation
Basic Plugin with xLink
Convert a standard Semantic Kernel plugin to use xLink authentication. This example shows a payment processing plugin calling an external service.
Before (API Key Auth)
public class PaymentPlugin { private readonly string _apiKey; public PaymentPlugin(string apiKey) { _apiKey = apiKey; // Stored credential ❌ } [KernelFunction] public async Task<string> ProcessPayment(decimal amount) { var client = new HttpClient(); client.DefaultRequestHeaders.Add("Authorization", $"Bearer {_apiKey}"); return await client.PostAsync("https://api.payments.com/charge", ...); } }
After (xLink Identity)
using PrivateMe.SemanticKernel.xLink; public class PaymentPlugin { // No API key needed ✅ [KernelFunction] [xLinkAuthenticated] // Automatic identity-based auth public async Task<string> ProcessPayment(decimal amount) { var client = xLinkHttp.CreateClient(); // Auto-signed requests return await client.PostAsync("https://api.payments.com/charge", ...); // Identity signature added automatically to request headers } }
Advanced Integration Patterns
Multi-Service Plugin
Plugin calling multiple external services with different identities.
public class OrderPlugin { [KernelFunction] [xLinkAuthenticated(Service = "payments")] public async Task ChargeCustomer(decimal amount) { var client = xLinkHttp.CreateClient("payments"); await client.PostAsync("https://payments.example.com/charge", ...); } [KernelFunction] [xLinkAuthenticated(Service = "shipping")] public async Task CreateShipment(string address) { var client = xLinkHttp.CreateClient("shipping"); await client.PostAsync("https://shipping.example.com/shipments", ...); } }
Capability-Based Access Control
Restrict plugin functions to specific capabilities using Trust Registry.
var registry = new TrustRegistry(); // Register plugin with limited capabilities await registry.RegisterAsync(paymentIdentity, new[] { "payments:charge", // Allowed "payments:refund" // Allowed // payments:admin NOT granted }); // Attach registry to kernel kernel.AddTrustRegistry(registry); // Calls to unauthorized capabilities fail fast await kernel.InvokeAsync("Payments", "AdminAction", ...); // Throws: UnauthorizedCapabilityException
Python Integration
Same pattern works in Python Semantic Kernel.
from private_me.semantic_kernel.xlink import PluginIdentity, xlink_authenticated class PaymentPlugin: # No API key needed @kernel_function @xlink_authenticated # Automatic identity auth async def process_payment(self, amount: float) -> str: client = xlink_http.create_client() # Auto-signed requests return await client.post("https://api.payments.com/charge", ...) # Register plugin identity = await PluginIdentity.create("PaymentPlugin") plugin = await xlink_plugin.wrap(PaymentPlugin(), identity) kernel.plugins.add_from_object(plugin, "Payments")
Migrate Existing Plugins to xLink
Step-by-step guide to converting existing API-key-based plugins to identity-based authentication.
Step 1: Identify Credential Storage
Find all locations where API keys, tokens, or credentials are stored.
// Environment variables var apiKey = Environment.GetEnvironmentVariable("PAYMENT_API_KEY"); // Constructor injection public PaymentPlugin(string apiKey) { ... } // Configuration files var apiKey = Configuration["PaymentApiKey"];
Step 2: Remove Credential Parameters
Delete API key parameters from constructors and method signatures.
Step 3: Add xLink Attributes
Annotate plugin functions with [xLinkAuthenticated] or @xlink_authenticated.
Step 4: Replace HTTP Client
Swap HttpClient for xLinkHttp.CreateClient() to get auto-signed requests.
Step 5: Create Identity Once
Generate plugin identity during application startup, not per-request.
// Startup.cs or Program.cs var paymentIdentity = await PluginIdentity.CreateAsync("PaymentPlugin"); services.AddSingleton(paymentIdentity); // Plugin uses injected identity var plugin = serviceProvider.GetRequiredService<PaymentPlugin>(); var authenticatedPlugin = await xLinkPlugin.WrapAsync(plugin, paymentIdentity);
Why Choose xLink for Semantic Kernel
Ready to Get Started?
Install the package and convert your first plugin in under 5 minutes. Full documentation, examples, and support available.
dotnet add package PrivateMe.SemanticKernel.xLink
Resources:
- xLink Documentation — Core identity platform
- Full API Reference — All methods and types
- Trust Registry Guide — Capability-based access control
- Contact Support — Questions or integration help