2017-07-18 177 views
2

經過php league oauth2服務器的安全改進後,Laravel護照授權失敗。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/laravel/passport/src/PassportServiceProvider.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; 
    } 

這是我的作品。但從技術上講,我無法編輯此文件。有沒有適合的解決方法?

回答

1

嘗試......

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

它解決了我的問題

+0

謝謝您的答覆。但這是給予許可的。問題在makeAuthorizationServer()中缺少setEncryptionKey()方法。護照維護人員表示它已修復版本v1.0.18標記。但尚未在護照v3中提供。 – Umanda

+0

供您參考:https://github.com/laravel/passport/issues/437 – Umanda