![](/img/trans.png)
[英]C# - Using Azure Key Vault with Azure Storage on Native App
[英]Is it possible to authenticate with an Azure Key Vault using a User Principle via a c# Winforms application?
我可以使用企業應用程序輕松地對 Azure KeyVault 進行身份驗證,但是這在已部署的環境中似乎不安全,因為我需要在應用程序本身中存儲 ClientID 和 ClientSecret,我更希望讓用戶在應用程序中使用AAD 登錄然后使用該登錄對 KeyVault 進行身份驗證,以確保任何連接的用戶都獲得授權。
這可能嗎?
謝謝你。
是的,這在技術上可以使用Azure.Identity
SDK 的InteractiveBrowserCredential
。 但是,通過這樣做,您需要授予用戶/組所需的權限(例如秘密獲取等)。 因此,如果您對此感到滿意,請繼續閱讀。 此外,您只需要在桌面應用程序中維護 AAD 應用程序的 TenantID 和 ClientID。
Azure.Security.KeyVault.Secrets
和Azure.Identity
// Create a new secret client using the Interactive credential from Azure.Identity
// This will prompt the user to login .
var client = new SecretClient(vaultUri: new Uri("https://<keyvault-name>.vault.azure.net/"),
credential: new InteractiveBrowserCredential("<tenant-id>", "<client-id>"));
// Retrieve a secret using the secret client.
var secret = await client.GetSecretAsync("<secret-name>");
瞧,就是這樣。 它將打開一個瀏覽器窗口,提示用戶登錄並從用戶原則繼續使用身份驗證令牌。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.