Skip to content

Commit 6169575

Browse files
League OAuth 2.0 server with Symfony - User, Client and Scope
1 parent dbd0311 commit 6169575

File tree

14 files changed

+742
-1
lines changed

14 files changed

+742
-1
lines changed

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"ext-ctype": "*",
77
"ext-iconv": "*",
88
"beberlei/assert": "^3.0",
9+
"league/oauth2-server": "^7.2",
910
"ramsey/uuid": "^3.8",
1011
"symfony/console": "*",
1112
"symfony/flex": "^1.1",

composer.lock

Lines changed: 292 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping">
2+
<entity name="App\Domain\Model\Client">
3+
<id name="id" column="id" type="string"/>
4+
<field name="name" type="string"/>
5+
<field name="secret" type="string"/>
6+
<field name="redirect" type="string"/>
7+
<field name="active" type="boolean"/>
8+
</entity>
9+
</doctrine-mapping>
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
namespace App\Application\Repository\Doctrine;
3+
4+
use App\Domain\Model\Client;
5+
use App\Domain\Repository\ClientRepositoryInterface;
6+
use Doctrine\Common\Persistence\ObjectRepository;
7+
use Doctrine\ORM\EntityManagerInterface;
8+
9+
final class ClientRepository implements ClientRepositoryInterface
10+
{
11+
private const ENTITY = Client::class;
12+
13+
/**
14+
* @var EntityManagerInterface
15+
*/
16+
private $entityManager;
17+
18+
/**
19+
* @var ObjectRepository
20+
*/
21+
private $objectRepository;
22+
23+
/**
24+
* UserRepository constructor.
25+
* @param EntityManagerInterface $entityManager
26+
*/
27+
public function __construct(
28+
EntityManagerInterface $entityManager
29+
) {
30+
$this->entityManager = $entityManager;
31+
$this->objectRepository = $this->entityManager->getRepository(self::ENTITY);
32+
}
33+
34+
/**
35+
* @param string $clientId
36+
* @return Client|null
37+
*/
38+
public function findActive(string $clientId): ?Client
39+
{
40+
return $this->objectRepository->findOneBy(['id' => $clientId, 'active' => true]);
41+
}
42+
}

0 commit comments

Comments
 (0)