Laravel Passport:部署到aws后缺少密钥 [英] Laravel Passport: Missing keys after deployment to aws
问题描述
我无法在aws弹性豆茎上设置幼虫护照.eb客户端设置正确,我可以部署代码更改.没有错误显示.
I'm having trouble setting up laravels passport on aws elastic beanstalk. The eb client is set up correctly and I can deploy code changes. No errors are shown.
但是,向laravel发送请求之后,错误500告诉我,我在"app/current/storage/oauth-public.key \"中缺少护照密钥.在本地一切正常.
However making requests to laravel results in error 500 afterwards, telling me I'm missing the passport keys in "app/current/storage/oauth-public.key\". Locally everything runs fine.
我想我缺少artisan命令"php artisanpassport:install",所以我将其添加到了composer文件中:
I guess I'm missing the artisan command "php artisan passport:install", so I added it in the composer file:
"post-install-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postInstall",
"@php artisan passport:install"
]
但显然,它不会创建密钥.
But apparently it does not create the keys.
要么运行eb deploy后未执行安装后挂钩,要么发生另一个错误,该错误使我无法创建密钥文件(缺少写入权限?)
Either the post-install hook is not executed after running eb deploy, or there is another error that does not let me create the key file (missing writing permission?)
如何验证安装后挂钩是否已执行?有人遇到过类似的问题吗?
How can I verify that the post-install hook is executed? Anyone had a similar issue?
我遵循了本期中的建议,但到目前为止没有帮助: https://github.com/laravel/passport/issues/418
I followed the suggestions in this issue but so far it did not help: https://github.com/laravel/passport/issues/418
更新:我进入应用程序并尝试手动运行php artisanpassport:install,这导致了错误.我必须首先授予对该文件夹(sudo chmod -R 777存储)的权限,然后它才能工作.不幸的是,每次我运行eb deploy时,密钥都会被删除,因此我每次都必须重做这些步骤-非常麻烦.任何人都找到了一种自动化的好方法吗?
UPDATE: I sshed into the app and tried to run php artisan passport:install manually, which resulted in an error. I had to give permissions first to the folder (sudo chmod -R 777 storage) then it worked. Unfortunatly the keys are deleted everytime I run eb deploy, so I would have to redo these steps every time - pretty cumbersome. Anyone has found a good way to automate this?
推荐答案
显然,此PR https://github.com/laravel/passport/pull/683 使envvars传递密钥成为可能.
Apparently this PR https://github.com/laravel/passport/pull/683 made possible to pass the keys by envvars.
/*
|--------------------------------------------------------------------------
| Encryption Keys
|--------------------------------------------------------------------------
|
| Passport uses encryption keys while generating secure access tokens for
| your application. By default, the keys are stored as local files but
| can be set via environment variables when that is more convenient.
|
*/
'private_key' => env('PASSPORT_PRIVATE_KEY'),
'public_key' => env('PASSPORT_PUBLIC_KEY'),
我还没有测试,但是很快.
I didn't test it yet but I will soon.
更新
我们尝试过,并且达到了4K的envvars大小限制: https://forums.aws.amazon.com/thread.jspa?messageID=618423򖾷
We tried it and we hit the envvars size limit of 4K: https://forums.aws.amazon.com/thread.jspa?messageID=618423򖾷
最后,我们最终改为使用CI.
At the end, we ended up using our CI instead.
这篇关于Laravel Passport:部署到aws后缺少密钥的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!