Laravel Passport授权失败

问题描述 投票:2回答:2

在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;
    }

这对我有用。但从技术上讲,我无法编辑此文件。这有什么合适的解决方案吗?

php laravel-5 oauth-2.0 laravel-passport
2个回答
1
投票

试试这个...

sudo chown www-data:www-data storage/oauth-*.key
sudo chmod 600 storage/oauth-*.key

它解决了我的问题


0
投票

确保您确实更新了laravel护照

"laravel/passport": "^7.0",

有关安全更新的更多详细信息,请访问https://laravel.com/docs/5.6/upgrade

© www.soinside.com 2019 - 2024. All rights reserved.