php - 如何以安全的方式使用应用程序的 GUI 将 API 密钥保存到 .env?
问题描述
我目前正在研究将存储来自许多来源的数据的应用程序。问题是每个月都会有 2-3 个新来源,所以我寻找一种方法来允许用户在我的应用程序中添加新密钥。数据将是高度敏感的,所以我想安全地进行。
我不想启用putenv()
功能或将 .env 文件作为文本读取。现在我@store
在控制器中的操作如下所示:
public function store(Request $request)
{
$this->validate($request, [
'customer_api' => 'required',
'secret_api' => 'required',
'edition_id' => 'required'
]);
$edition = $request->input('edition_id');
$secret = $request->input('secret_api');
$customer = $request->input('customer_api');
putenv("GF_SECRET_ED$edition=$secret");
putenv("GF_CUSTOMER_ED$edition=$customer");
return redirect('/editions/' . $edition . "#dev")->with('success', 'API keys added');
}
我正在寻找一种解决方案,允许我将这些密钥添加到,然后在
无法在文档中找到任何内容中.env
定义那些 3rd 方密钥。config/services.php
在 Laravel 6 上工作。
先感谢您!
解决方案
在您的应用程序中修改 env 不正确
你有两个选择:
1-使用数据库
2-使用文件,也许使用 json 格式来轻松检索数据