【问题标题】:Laravel API Authentication (Passport); ErrorException in CryptKey.phpLaravel API 身份验证(护照); CryptKey.php 中的 ErrorException
【发布时间】:2018-06-16 03:08:08
【问题描述】:
CryptKey.php 第 57 行中的 ErrorException:
密钥文件“file://C:\wamp\www\project\public_html\storage\oauth-private.key”权限不正确,应为 600 或 660 而不是 666
我的配置如下:
- Windows 10 64 位
- WampServer 3.1.0
- Apache 2.4.27
- PHP 7.0.23
- Laravel 框架版本 5.3.31
- 作曲家需要 laravel/passport=~1.0
知道怎么解决吗?
【问题讨论】:
标签:
laravel
laravel-passport
【解决方案1】:
您可以在第 57 行关闭文件检查权限
您的 CryptKey 路径是 vendor/league/oauth2-server/src/CryptKey.php
在第 48 行将其设置为 false 或在您的 CryptKey.php 中评论以下块
if ($keyPermissionsCheck === true) {
// Verify the permissions of the key
$keyPathPerms = decoct(fileperms($keyPath) & 0777);
if (in_array($keyPathPerms, ['600', '660'], true) === false) {
trigger_error(sprintf(
'Key file "%s" permissions are not correct, should be 600 or 660 instead of %s',
$keyPath,
$keyPathPerms
), E_USER_NOTICE);
}
}
keyPermissionsCheck 将其设置为 false。
希望这会有所帮助。
【解决方案2】:
只需将 oauth-private.key 文件 CHMOD 到 600 或 660。我看到您使用的是 Windows,因此您肯定可以按照 this post 中的说明进行操作。