Closed dlabey closed 9 years ago
No, it uses PHP's native sessions.
Ok, thanks, do you have an example of how to use Redis? Otherwise I could fork your repo and then submit a pull for Redis if its not implemented yet.
(Not my repo, I'm just a happy user!)
The underlying library actually has support for Redis, although this package doesn't have a way to instantiate it with a connected Predis instance.
I looked into it briefly (when I thought a bug I was having was due to storage - it wasn't) and implemented a LaravelRedisStorage
class, which extends from OAuth\Common\Storage\Redis
and implements OAuth\Common\Storage\TokenStorageInterface
. All you would have to do is override the constructor to pass in a Predis instance (obtained by a \Redis::connection()
, easy!) to the parent. I can't fully remember what $key
and $stateKey
needed to be, I dare say a closer look how the storage is instantiated might help. Note that the LaravelRedisStorage
class needs to be in the OAuth\Common\Storage
namespace, as that is how the storage provider is configured. It will need autoloaded separately.
Thank you for the answer, seeing the interface I see how it is done.
In case anyone else stumbles across this, here is my solution as suggested by @maknz.
The class I created looked like so:
<?php
namespace OAuth\Common\Storage;
use Predis\Client as Predis;
class LaravelRedisStorage extends Redis implements TokenStorageInterface {
public function __construct()
{
$this->redis = \Redis::connection();
$this->key = 'oauth_user_tokens';
$this->stateKey = 'oauth_user_states';
$this->cachedTokens = array();
$this->cachedStates = array();
}
}
I autoloaded this in my composer.json
file and set it to be used in app/config/packages/artdarek/oauth-4-laravel/config.php
like so:
/**
* Storage
*/
'storage' => 'LaravelRedisStorage',
If we have Laravel set to use Redis for sessions and our storage is set to Session, will this use Redis?