Skip to content

Commit 43feb68

Browse files
committed
Add initial files
1 parent f998005 commit 43feb68

28 files changed

+1570
-6
lines changed

.gitignore

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
tmp/*
2-
[Cc]onfig/core.php
3-
[Cc]onfig/database.php
4-
app/tmp/*
5-
app/[Cc]onfig/core.php
6-
app/[Cc]onfig/database.php
71
!empty
2+
vendor/
3+
plugins/

composer.json

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"name": "uafrica.com/oauth-server",
3+
"description": "OAuth Server for CakePHP 3 using the PHP League's OAuth Server",
4+
"type": "cakephp-plugin",
5+
"keywords": ["cakephp", "oauth", "oauth2", "oauth server", "oauth2 server"],
6+
"require": {
7+
"php": ">= 5.5",
8+
"cakephp/cakephp": "3.0.x-dev",
9+
"league/oauth2-server": "~4.1",
10+
"cakephp/migrations": "dev-master"
11+
},
12+
"require-dev": {
13+
"phpunit/phpunit": "~4.5"
14+
},
15+
"autoload": {
16+
"psr-4": {
17+
"OAuth\\": "src"
18+
}
19+
},
20+
"autoload-dev": {
21+
"psr-4": {
22+
"Cake\\Test\\": "./vendor/cakephp/cakephp/tests",
23+
"OAuth\\Test\\": "tests"
24+
}
25+
},
26+
"license": "MIT",
27+
"authors": [
28+
{
29+
"name": "Walther Lalk",
30+
"email": "[email protected]"
31+
}
32+
]
33+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,266 @@
1+
<?php
2+
use Phinx\Migration\AbstractMigration;
3+
4+
class InitialMigration extends AbstractMigration
5+
{
6+
/**
7+
* Change Method.
8+
*
9+
* More information on this method is available here:
10+
* http://docs.phinx.org/en/latest/migrations.html#the-change-method
11+
* @return void
12+
*/
13+
public function change()
14+
{
15+
$table = $this->table('oauth_access_tokens', ['id' => false, 'primary_key' => ['oauth_token']]);
16+
$table
17+
->addColumn(
18+
'oauth_token',
19+
'string',
20+
[
21+
'default' => null,
22+
'limit' => 40,
23+
'null' => false,
24+
]
25+
)
26+
->addColumn(
27+
'session_id',
28+
'integer',
29+
[
30+
'default' => null,
31+
'limit' => 11,
32+
'null' => false,
33+
]
34+
)
35+
->addColumn(
36+
'expires',
37+
'integer',
38+
[
39+
'default' => null,
40+
'limit' => 11,
41+
'null' => false,
42+
]
43+
)
44+
->create();
45+
$table = $this->table('oauth_auth_codes', ['id' => false, 'primary_key' => ['code']]);
46+
$table
47+
->addColumn(
48+
'code',
49+
'string',
50+
[
51+
'default' => null,
52+
'limit' => 40,
53+
'null' => false,
54+
]
55+
)
56+
->addColumn(
57+
'session_id',
58+
'integer',
59+
[
60+
'default' => null,
61+
'limit' => 11,
62+
'null' => false,
63+
]
64+
)
65+
->addColumn(
66+
'redirect_uri',
67+
'string',
68+
[
69+
'default' => null,
70+
'limit' => 200,
71+
'null' => false,
72+
]
73+
)
74+
->addColumn(
75+
'expires',
76+
'integer',
77+
[
78+
'default' => null,
79+
'limit' => 11,
80+
'null' => false,
81+
]
82+
)
83+
->create();
84+
$table = $this->table('oauth_clients', ['id' => false, 'primary_key' => ['client_id']]);
85+
$table
86+
->addColumn(
87+
'client_id',
88+
'string',
89+
[
90+
'default' => null,
91+
'limit' => 20,
92+
'null' => false,
93+
]
94+
)
95+
->addColumn(
96+
'client_secret',
97+
'string',
98+
[
99+
'default' => null,
100+
'limit' => 40,
101+
'null' => false,
102+
]
103+
)
104+
->addColumn(
105+
'redirect_uri',
106+
'string',
107+
[
108+
'default' => null,
109+
'limit' => 255,
110+
'null' => false,
111+
]
112+
)
113+
->addColumn(
114+
'parent_model',
115+
'string',
116+
[
117+
'default' => null,
118+
'limit' => 200,
119+
'null' => true,
120+
]
121+
)
122+
->addColumn(
123+
'parent_id',
124+
'integer',
125+
[
126+
'default' => null,
127+
'limit' => 11,
128+
'null' => true,
129+
]
130+
)
131+
->create();
132+
$table = $this->table('oauth_sessions');
133+
$table
134+
->addColumn(
135+
'owner_model',
136+
'string',
137+
[
138+
'limit' => 200
139+
]
140+
)
141+
->addColumn(
142+
'owner_id',
143+
'integer',
144+
[
145+
'limit' => 11
146+
]
147+
)
148+
->addColumn(
149+
'client_id',
150+
'string',
151+
[
152+
'limit' => 20
153+
]
154+
)
155+
->addColumn(
156+
'client_redirect_uri',
157+
'string',
158+
[
159+
'default' => null,
160+
'limit' => 200,
161+
'null' => true
162+
]
163+
)
164+
->create();
165+
$table = $this->table('oauth_scopes', ['id' => false, 'primary_key' => ['id']]);
166+
$table
167+
->addColumn(
168+
'id',
169+
'string',
170+
[
171+
'default' => null,
172+
'limit' => 40
173+
]
174+
)
175+
->addColumn(
176+
'description',
177+
'string',
178+
[
179+
'default' => null,
180+
'limit' => 200
181+
]
182+
)
183+
->create();
184+
$table = $this->table('oauth_refresh_tokens', ['id' => false, 'primary_key' => ['refresh_token']]);
185+
$table
186+
->addColumn(
187+
'refresh_token',
188+
'string',
189+
[
190+
'default' => null,
191+
'limit' => 40,
192+
'null' => false,
193+
]
194+
)
195+
->addColumn(
196+
'oauth_token',
197+
'string',
198+
[
199+
'default' => null,
200+
'limit' => 40,
201+
'null' => false,
202+
]
203+
)
204+
->addColumn(
205+
'expires',
206+
'integer',
207+
[
208+
'default' => null,
209+
'limit' => 11,
210+
'null' => false,
211+
]
212+
)
213+
->create();
214+
$table = $this->table('oauth_access_token_scopes');
215+
$table
216+
->addColumn(
217+
'oauth_token',
218+
'string',
219+
[
220+
'length' => 40
221+
]
222+
)
223+
->addColumn(
224+
'scope_id',
225+
'string',
226+
[
227+
'length' => 40
228+
]
229+
)
230+
->create();
231+
$table = $this->table('oauth_auth_code_scopes');
232+
$table
233+
->addColumn(
234+
'auth_code',
235+
'string',
236+
[
237+
'length' => 40
238+
]
239+
)
240+
->addColumn(
241+
'scope_id',
242+
'string',
243+
[
244+
'length' => 40
245+
]
246+
)
247+
->create();
248+
$table = $this->table('oauth_session_scopes');
249+
$table
250+
->addColumn(
251+
'session_id',
252+
'integer',
253+
[
254+
'length' => 11
255+
]
256+
)
257+
->addColumn(
258+
'scope_id',
259+
'string',
260+
[
261+
'length' => 40
262+
]
263+
)
264+
->create();
265+
}
266+
}

config/routes.php

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
\Cake\Routing\Router::plugin('OAuth', ['path' => '/oauth'], function(\Cake\Routing\RouteBuilder $routes) {
3+
$routes->connect(
4+
'/',
5+
[
6+
'controller' => 'OAuth',
7+
'action' => 'oauth'
8+
]
9+
);
10+
$routes->connect(
11+
'/authorize',
12+
[
13+
'controller' => 'OAuth',
14+
'action' => 'authorize'
15+
]
16+
);
17+
$routes->connect(
18+
'/access_token',
19+
[
20+
'controller' => 'OAuth',
21+
'action' => 'accessToken'
22+
]
23+
);
24+
});

0 commit comments

Comments
 (0)