我使用的blazor web组装应用程序不是个人网站托管的asp net core.这个网站集成了内容CMS,它需要api密钥、预览密钥和空间id.我目前正在我自己的应用程序设置中存储这些信息.将IConfiguration注入到我的服务中,然后通过GetSection方法访问这些值.
它们的形式如下:
"DeliveryApiKey": "A",
"ManagementApiKey": "not used",
"PreviewApiKey": "B",
"SpaceId": "C",```
这对于在本地运行是很好的,但是经过一些在线研究之后,如果部署并反编译DLL,这些密钥对用户来说将是可读和可见的.
blazor web组装应用程序存储api密钥的最佳方式是什么?
*编辑,这就是我如何使用这些密钥来访问内容丰富的CDA.这是基于文档的方法.
{
var apiKey = _configuration.GetSection("ContentfulOptions").GetSection("DeliveryApiKey").Value;
var previewKey = _configuration.GetSection("ContentfulOptions").GetSection("PreviewApiKey").Value;
var spaceid = _configuration.GetSection("ContentfulOptions").GetSection("SpaceId").Value;
var httpClient = new HttpClient();
var client = new ContentfulClient(httpClient, apiKey, previewKey, spaceid);
return client;
}