在php league oauth2服务器的安全性改进之后,Laravel护照授权失败了。
例外说
您必须设置加密密钥以提高此库的安全性 - 有关https://oauth2.thephpleague.com/v5-security-improvements/的更多信息,请参阅此页面
根据他们的文档,必须设置加密密钥。
即
// Setup the authorization server
$server = new AuthorizationServer(
$clientRepository,
$accessTokenRepository,
$scopeRepository,
$privateKeyPath,
$publicKeyPath
);
$server->setEncryptionKey('lxZFUEsBCJ2Yb14IF2ygAHI5N4+ZAUXXaSeeJm6+twsUmIen');
但Laravel护照当前版本不包含此修复程序。
我所做的是手动添加setEncryptionKey()
/vendor/拉Ravel/passport/双人床/passport service provider.PHP
public function makeAuthorizationServer()
{
$server = new AuthorizationServer(
$this->app->make(Bridge\ClientRepository::class),
$this->app->make(Bridge\AccessTokenRepository::class),
$this->app->make(Bridge\ScopeRepository::class),
'file://'.Passport::keyPath('oauth-private.key'),
'file://'.Passport::keyPath('oauth-public.key')
);
$server->setEncryptionKey('lxZFUEsBCJ2Yb14IF2ygAHI5N4+ZAUXXaSeeJm6+twsUmIen');
return $server;
}
这对我有用。但从技术上讲,我无法编辑此文件。这有什么合适的解决方案吗?
试试这个...
sudo chown www-data:www-data storage/oauth-*.key
sudo chmod 600 storage/oauth-*.key
它解决了我的问题