2016-08-16 32 views
0

私は新しいOauthプロバイダのためにLaravel Socialisteを拡張していますが、authorize URLを変更するという単純な問題に問題があります。Laravel RedirectResponseを無効にします

RedirectResponseによって生成されたURLはスコープデリミタ用%2C代わりに+、例えば、https://mycustomerprovider.com/oauth/authorize?scope=blah%2Cblahagainを有し、したがって、私は、この例mycustomproviderでは、使用している特定のプロバイダに障害が発生しました。

誰でもこの承認URLを変更して%2C+に変更する方法を知っていますか?

return Socialite::driver('mycustomprovider')->redirect();

あなたvar_dump(Socialite::driver('mycustomprovider')->redirect())場合は、ここではそれが含まれているものです:

RedirectResponse {#886 ▼ 
    #targetUrl: "http://" 
    +headers: ResponseHeaderBag {#888 ▶} 
    #content: """ 
    <!DOCTYPE html>\n 
    <html>\n 
     <head>\n 
      <meta charset="UTF-8" />\n 
      <meta http-equiv="refresh" content="1;url=https://mycustomerprovider.com/oauth/authorize?scope=blah%2Cblahagain" />\n 
    \n 
      <title>Redirecting to https://mycustomerprovider.com/oauth/authorize?scope=blah%2Cblahagain</title>\n 
     </head>\n 
     <body>\n 
      Redirecting to <a href="https://mycustomerprovider.com/oauth/authorize?scope=blah%2Cblahagain</a>.\n 
     </body>\n 
    </html> 
    """ 
    #version: "1.0" 
    #statusCode: 302 
    #statusText: "Found" 
    #charset: null 
} 

答えて

1

あなたはミドルウェア\ \ のApp \ HTTPではこの

php artisan make:middleware ReplaceMiddleware 

のための簡単なミドルウェアを使用する必要がありますReplaceMiddleware.php

public function handle($request, Closure $next, $guard = null) 
{ 
    $response = $next($request); 
    $response->setContent(str_replace('%2C','+',$response->getContent())); 
    return $response; 
} 

コントローラにあります。 __construct方法アプリで

$this->middleware('replace_response'); 

\でHTTP Kernel.php \。あなたがやった

'replace_response' => \App\Http\Middleware\ReplaceMiddleware::class, 

$ routeMiddleware配列に追加します。それを試してみてください!

関連する問題