-
Notifications
You must be signed in to change notification settings - Fork 450
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clean integration of CouchDB #524
base: master
Are you sure you want to change the base?
Changes from all commits
0f7648f
9438cfb
2e9c064
8261b6a
214452f
7fc056d
a57222f
a9fc0a8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the FOSOAuthServerBundle package. | ||
* | ||
* (c) FriendsOfSymfony <http://friendsofsymfony.github.com/> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace FOS\OAuthServerBundle\CouchDocument; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we move MongoDB to make way for CouchDB? This way, one of them seems "more important". There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think Apache CouchDB can have real advantage. For my project, I use it for scalability, and master-master replication capability. But, like you said, library are not up-to-date, I try to make some PR to keep these libraries usable with Symfony 3.X but they are not ready for 4 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I meant, should we move the MongoDB models to say |
||
|
||
use FOS\OAuthServerBundle\Model\AccessToken as BaseAccessToken; | ||
|
||
class AccessToken extends BaseAccessToken | ||
{ | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the FOSOAuthServerBundle package. | ||
* | ||
* (c) FriendsOfSymfony <http://friendsofsymfony.github.com/> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace FOS\OAuthServerBundle\CouchDocument; | ||
|
||
use FOS\OAuthServerBundle\Model\AccessTokenManagerInterface; | ||
|
||
class AccessTokenManager extends TokenManager implements AccessTokenManagerInterface | ||
{ | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the FOSOAuthServerBundle package. | ||
* | ||
* (c) FriendsOfSymfony <http://friendsofsymfony.github.com/> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace FOS\OAuthServerBundle\CouchDocument; | ||
|
||
use FOS\OAuthServerBundle\Model\AuthCode as BaseAuthCode; | ||
|
||
/** | ||
* @author Richard Fullmer <[email protected]> | ||
*/ | ||
class AuthCode extends BaseAuthCode | ||
{ | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the FOSOAuthServerBundle package. | ||
* | ||
* (c) FriendsOfSymfony <http://friendsofsymfony.github.com/> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace FOS\OAuthServerBundle\CouchDocument; | ||
|
||
use Doctrine\ODM\CouchDB\DocumentManager; | ||
use Doctrine\ODM\CouchDB\DocumentRepository; | ||
use FOS\OAuthServerBundle\Model\AuthCodeInterface; | ||
use FOS\OAuthServerBundle\Model\AuthCodeManager as BaseAuthCodeManager; | ||
|
||
class AuthCodeManager extends BaseAuthCodeManager | ||
{ | ||
/** | ||
* @var DocumentManager | ||
*/ | ||
protected $dm; | ||
|
||
/** | ||
* @var DocumentRepository | ||
*/ | ||
protected $repository; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected $class; | ||
|
||
public function __construct(DocumentManager $dm, $class) | ||
{ | ||
$this->dm = $dm; | ||
$this->repository = $dm->getRepository($class); | ||
$this->class = $class; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getClass() | ||
{ | ||
return $this->class; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function findAuthCodeBy(array $criteria) | ||
{ | ||
return $this->repository->findOneBy($criteria); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function updateAuthCode(AuthCodeInterface $authCode) | ||
{ | ||
$this->dm->persist($authCode); | ||
$this->dm->flush(); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function deleteAuthCode(AuthCodeInterface $authCode) | ||
{ | ||
$this->dm->remove($authCode); | ||
$this->dm->flush(); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function deleteExpired() | ||
{ | ||
return null; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the FOSOAuthServerBundle package. | ||
* | ||
* (c) FriendsOfSymfony <http://friendsofsymfony.github.com/> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace FOS\OAuthServerBundle\CouchDocument; | ||
|
||
use FOS\OAuthServerBundle\Model\Client as BaseClient; | ||
|
||
class Client extends BaseClient | ||
{ | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the FOSOAuthServerBundle package. | ||
* | ||
* (c) FriendsOfSymfony <http://friendsofsymfony.github.com/> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace FOS\OAuthServerBundle\CouchDocument; | ||
|
||
use Doctrine\ODM\CouchDB\DocumentManager; | ||
use Doctrine\ODM\CouchDB\DocumentRepository; | ||
use FOS\OAuthServerBundle\Model\ClientInterface; | ||
use FOS\OAuthServerBundle\Model\ClientManager as BaseClientManager; | ||
|
||
class ClientManager extends BaseClientManager | ||
{ | ||
/** | ||
* @var DocumentManager | ||
*/ | ||
protected $dm; | ||
|
||
/** | ||
* @var DocumentRepository | ||
*/ | ||
protected $repository; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected $class; | ||
|
||
public function __construct(DocumentManager $dm, $class) | ||
{ | ||
$this->dm = $dm; | ||
$this->repository = $dm->getRepository($class); | ||
$this->class = $class; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getClass() | ||
{ | ||
return $this->class; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function findClientBy(array $criteria) | ||
{ | ||
$client = $this->repository->findOneBy(['randomId' => $criteria['randomId']]); | ||
|
||
if ($client !== null) { | ||
if ($client->getId() === $criteria['id']) { | ||
return $client; | ||
} | ||
} | ||
|
||
return null; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function updateClient(ClientInterface $client) | ||
{ | ||
$this->dm->persist($client); | ||
$this->dm->flush(); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function deleteClient(ClientInterface $client) | ||
{ | ||
$this->dm->remove($client); | ||
$this->dm->flush(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the FOSOAuthServerBundle package. | ||
* | ||
* (c) FriendsOfSymfony <http://friendsofsymfony.github.com/> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace FOS\OAuthServerBundle\CouchDocument; | ||
|
||
use FOS\OAuthServerBundle\Model\RefreshToken as BaseRefreshToken; | ||
|
||
class RefreshToken extends BaseRefreshToken | ||
{ | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the FOSOAuthServerBundle package. | ||
* | ||
* (c) FriendsOfSymfony <http://friendsofsymfony.github.com/> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace FOS\OAuthServerBundle\CouchDocument; | ||
|
||
use FOS\OAuthServerBundle\Model\RefreshTokenManagerInterface; | ||
|
||
class RefreshTokenManager extends TokenManager implements RefreshTokenManagerInterface | ||
{ | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is incorrect, you don't typehint against a debug version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I totally don't understand why the initial version is not working and your comment. I just change this following error message, but I'm really not an expert.