Skip to content

Commit 8074534

Browse files
committed
fixes cs
1 parent 143aa9b commit 8074534

File tree

6 files changed

+169
-2
lines changed

6 files changed

+169
-2
lines changed

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
}
4141
],
4242
"scripts": {
43-
"cs-check": "phpcs --colors -p --extensions=php --standard=vendor/cakephp/cakephp-codesniffer/CakePHP --ignore=config/Migrations/* ./src ./tests ./config",
43+
"cs-check": "phpcs --colors -psn --extensions=php --standard=vendor/cakephp/cakephp-codesniffer/CakePHP --ignore=config/Migrations/* ./src ./tests ./config",
4444
"cs-fix": "phpcbf -p --extensions=php --standard=vendor/cakephp/cakephp-codesniffer/CakePHP --ignore=config/Migrations/* ./src ./tests ./config"
4545
}
4646
}

phpcs.xml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ruleset name="CakePHP Plugin">
3+
<exclude-pattern>vendor/*</exclude-pattern>
4+
<exclude-pattern>config/Migrations/*</exclude-pattern>
5+
<exclude-pattern>config/Seeds/*</exclude-pattern>
6+
<exclude-pattern>Template/Bake/*</exclude-pattern>
7+
<exclude-pattern>webroot/*</exclude-pattern>
8+
9+
<rule ref="./vendor/cakephp/cakephp-codesniffer/CakePHP"/>
10+
</ruleset>
+149
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
<?php
2+
3+
namespace OAuthServer\Bridge;
4+
5+
use Defuse\Crypto\Key;
6+
use League\OAuth2\Server\AuthorizationServer;
7+
use League\OAuth2\Server\Repositories\AccessTokenRepositoryInterface;
8+
use League\OAuth2\Server\Repositories\ClientRepositoryInterface;
9+
use League\OAuth2\Server\Repositories\ScopeRepositoryInterface;
10+
use OAuthServer\Bridge\Repository\AccessTokenRepository;
11+
use OAuthServer\Bridge\Repository\ClientRepository;
12+
use OAuthServer\Bridge\Repository\ScopeRepository;
13+
14+
/**
15+
* Build AuthorizationServer
16+
*/
17+
class AuthorizationServerFactory
18+
{
19+
/**
20+
* @var ClientRepositoryInterface
21+
*/
22+
private $clientRepository;
23+
24+
/**
25+
* @var AccessTokenRepositoryInterface
26+
*/
27+
private $accessTokenRepository;
28+
29+
/**
30+
* @var ScopeRepositoryInterface
31+
*/
32+
private $scopeRepository;
33+
34+
/**
35+
* @var string
36+
*/
37+
private $privateKeyPath;
38+
39+
/**
40+
* @var Key|string
41+
*/
42+
private $encryptionKey;
43+
44+
/**
45+
* @return AuthorizationServer
46+
*/
47+
public function create()
48+
{
49+
return new AuthorizationServer(
50+
$this->getClientRepository(),
51+
$this->getAccessTokenRepository(),
52+
$this->getScopeRepository(),
53+
$this->getPrivateKeyPath(),
54+
$this->getEncryptionKey()
55+
);
56+
}
57+
58+
/**
59+
* @return ClientRepositoryInterface
60+
*/
61+
public function getClientRepository(): ClientRepositoryInterface
62+
{
63+
if ($this->clientRepository) {
64+
$this->clientRepository = new ClientRepository();
65+
}
66+
67+
return $this->clientRepository;
68+
}
69+
70+
/**
71+
* @param ClientRepositoryInterface $clientRepository the Repository
72+
*/
73+
public function setClientRepository(ClientRepositoryInterface $clientRepository): void
74+
{
75+
$this->clientRepository = $clientRepository;
76+
}
77+
78+
/**
79+
* @return AccessTokenRepositoryInterface
80+
*/
81+
public function getAccessTokenRepository(): AccessTokenRepositoryInterface
82+
{
83+
if (!$this->accessTokenRepository) {
84+
$this->accessTokenRepository = new AccessTokenRepository();
85+
}
86+
87+
return $this->accessTokenRepository;
88+
}
89+
90+
/**
91+
* @param AccessTokenRepositoryInterface $accessTokenRepository the Repository
92+
*/
93+
public function setAccessTokenRepository(AccessTokenRepositoryInterface $accessTokenRepository): void
94+
{
95+
$this->accessTokenRepository = $accessTokenRepository;
96+
}
97+
98+
/**
99+
* @return ScopeRepositoryInterface
100+
*/
101+
public function getScopeRepository(): ScopeRepositoryInterface
102+
{
103+
if (!$this->scopeRepository) {
104+
$this->scopeRepository = new ScopeRepository();
105+
}
106+
107+
return $this->scopeRepository;
108+
}
109+
110+
/**
111+
* @param ScopeRepositoryInterface $scopeRepository the Repository
112+
*/
113+
public function setScopeRepository(ScopeRepositoryInterface $scopeRepository): void
114+
{
115+
$this->scopeRepository = $scopeRepository;
116+
}
117+
118+
/**
119+
* @return string
120+
*/
121+
public function getPrivateKeyPath(): string
122+
{
123+
return $this->privateKeyPath;
124+
}
125+
126+
/**
127+
* @param string $privateKeyPath the PrivateKey's path
128+
*/
129+
public function setPrivateKeyPath(string $privateKeyPath): void
130+
{
131+
$this->privateKeyPath = $privateKeyPath;
132+
}
133+
134+
/**
135+
* @return Key|string
136+
*/
137+
public function getEncryptionKey(): Key
138+
{
139+
return $this->encryptionKey;
140+
}
141+
142+
/**
143+
* @param Key|string $encryptionKey the Encryption key string or Key object
144+
*/
145+
public function setEncryptionKey($encryptionKey): void
146+
{
147+
$this->encryptionKey = $encryptionKey;
148+
}
149+
}

src/Bridge/Entity/User.php

+5
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ class User implements UserEntityInterface
1414
*/
1515
private $id;
1616

17+
/**
18+
* User constructor.
19+
*
20+
* @param string|int $identifier the user identifier
21+
*/
1722
public function __construct($identifier)
1823
{
1924
$this->id = $identifier;

src/Bridge/Repository/UserRepository.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class UserRepository implements UserRepositoryInterface
2121
/**
2222
* UserRepository constructor.
2323
*
24-
* @param UserFinderByUserCredentialsInterface $finder
24+
* @param UserFinderByUserCredentialsInterface $finder user finder
2525
*/
2626
public function __construct(UserFinderByUserCredentialsInterface $finder)
2727
{

src/Model/Table/OauthClientsTable.php

+3
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ public function initialize(array $config): void
3737
$this->setDisplayField('name');
3838
}
3939

40+
/**
41+
* {@inheritDoc}
42+
*/
4043
protected function _initializeSchema(TableSchema $schema): TableSchema
4144
{
4245
$schema->setColumnType('redirect_uri', 'json');

0 commit comments

Comments
 (0)