azure - 如何从 Azure ACS 获取对称 key ?

标签 azure acs

我在使用 ACS 管理 API 和对称 key 时遇到一些问题。当我通过 API 将服务身份添加到 ACS 并设置对称 key 时,似乎 ACS 正在更改我发送的 key 。

如果我传入“xyz123”作为对称 key 的值...当我转到 ACS 管理门户并查看该值时,它是一个不同的字符串;可以说“AHDyDG6236=”。

如果我向 API 询问值,它会返回给我“xyz123”(ServiceIdentityKey.Value)。

您需要登录的值为“AHDyDG6236=”,但如果不转到 ACS 门户并单击“显示 key ”按钮,就无法获取该值吗?

有没有办法无需进入 ACS 管理门户即可获取对称 key 的可用值?

这里有一些示例代码来说明我正在谈论的内容。它基于此处找到的示例:http://msdn.microsoft.com/en-us/library/hh135148.aspx

    var svc = ManagementServiceHelper.CreateManagementServiceClient();
    var password = Encoding.UTF8.GetBytes("password");
    var serviceIdentity = svc.CreateServiceIdentity("testSI", password, ServiceIdentityKeyType.Symmetric, ServiceIdentityKeyUsage.Password);
    serviceIdentity.Description = "service identity for testing";
    svc.SaveChangesBatch();
    var svc2 = ManagementServiceHelper.CreateManagementServiceClient();
    var si = svc2.GetServiceIdentityByName("testSI");
    Console.WriteLine(Encoding.UTF8.GetChars(si.ServiceIdentityKeys[0].Value)); //prints out "password"

运行此代码后,转到 ACS 门户并单击对称 key ,然后单击“显示 key ”,它会显示生成的/散列值...这是您进行身份验证所需的值...但是有没有办法从 API 获取该值?

最佳答案

您遇到的问题是在 Encoding.UTF8.GetBytes("password") 中。

发送到服务器的字符串被编码为 base64,因此您需要使用不同的函数来获取字节数组。 Convert.FromBase64String("密码")

此页面上的示例是错误的,但我已联系他们的团队让他们知道,并希望他们能够修复它。 How to use Access Control Service

关于azure - 如何从 Azure ACS 获取对称 key ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19963680/

相关文章:

azure - 在 Azure 中动态创建/删除 VM 以最大限度地降低成本

使用条件访问策略的 Azure Active Directory 多重身份验证不起作用

azure - Windows Azure 虚拟机上的被动 FTP

asp.net - Windows Azure 基于角色的身份验证 (ACS)

azure - 如何对 Flaky Azure 函数应用程序行为进行故障排除?

azure - 更新到 Azure SDK 2.0 后无法加载 'Microsoft.WindowsAzure.ServiceRuntime' 程序集

acs - 从 Azure ACS 下载登录页面后,如何使返回 URL 再次正常工作?

azure - Azure ACS 的自定义登录页面不起作用

c# - 客户端 WPF 应用程序如何通过 Azure 上的 WCF 服务进行身份验证?

azure - Kubernetes NodeLost/NotReady/高 IO 磁盘