laravel / socialite

Laravel wrapper around OAuth 1 & OAuth 2 libraries.

Home Page:https://laravel.com/docs/socialite

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to use updated config object when using Laravel Octane

aprokopenko opened this issue · comments

Socialite Version

5.6.1

Laravel Version

10.12.0

PHP Version

8.2.6

Database Driver & Version

MySQL 8.0.30 (official docker image)

Description

When switching our project to Octane (v2) we found out, that Socialite package doesn't work.

We have RESTful API and provide social URLs with separate endpoint. Also we have dynamic redirect URLs with CSRF token inside to prevent some kind of attack.

SocialiteManager::driver() method use config object like "services.{service}" to create drivers and 'redirect' key is mandatory. Before (with PHP-FPM) we just set redirect on each endpoint call with config(['services.{service}.redirect' => $url]) and it works fine.
But after switching to Octane we get 500 error, that redirect key is underfined.

After deep debugging of this problem, we found out that Octane reset SocialiteManager on each request and assign new $container object to it. However, SocialiteManager is already booted and has $this->config property, which was loaded at the very beginning from previous requests and this object stays the same and contain outdated data.

So if I manipulate with config object of the Container, it doesn't affect the SocialiteManager $this->config and this leads to 500 error in our case.

I prepared a Pull Request to fix this. Would be great to release a hotfix with it.

Steps To Reproduce

  • Configure octane with socialite environment
  • Do not configure driver in services.php
  • Create some route to get oauth redirect url
  • Set config() object for example for Google dynamically inside route (config(['services.google' => $yourCredentials])
  • Try to get google driver with Socialite::driver('google');
  • You will get fatal error that required keys are empty

(same scenario works fine with PHP-FPM)

Pull request: #639

Fixed: #639. The release will happen during this week.