@@ -199,6 +199,8 @@ private function createCassandraDb(Cassandra $storage)
199199
200200 $ storage ->setScope ('clientscope1 clientscope2 clientscope3 ' , 'Test Default Scope Client ID 2 ' );
201201 $ storage ->setScope ('clientscope3 ' , 'Test Default Scope Client ID 2 ' , 'default ' );
202+
203+ $ storage ->setClientKey ('oauth_test_client ' , $ this ->getTestPublicKey (), 'test_subject ' );
202204 }
203205
204206 private function createSqliteDb (\PDO $ pdo )
@@ -222,13 +224,14 @@ private function createMysqlDb(\PDO $pdo)
222224
223225 public function runPdoSql (\PDO $ pdo )
224226 {
225- $ pdo ->exec ('CREATE TABLE oauth_clients (client_id TEXT, client_secret TEXT, redirect_uri TEXT, grant_types TEXT, scope TEXT, user_id TEXT) ' );
227+ $ pdo ->exec ('CREATE TABLE oauth_clients (client_id TEXT, client_secret TEXT, redirect_uri TEXT, grant_types TEXT, scope TEXT, user_id TEXT, public_key TEXT ) ' );
226228 $ pdo ->exec ('CREATE TABLE oauth_access_tokens (access_token TEXT, client_id TEXT, user_id TEXT, expires DATETIME, scope TEXT) ' );
227229 $ pdo ->exec ('CREATE TABLE oauth_authorization_codes (authorization_code TEXT, client_id TEXT, user_id TEXT, redirect_uri TEXT, expires DATETIME, scope TEXT) ' );
228230 $ pdo ->exec ('CREATE TABLE oauth_users (username TEXT, password TEXT, first_name TEXT, last_name TEXT, scope TEXT) ' );
229231 $ pdo ->exec ('CREATE TABLE oauth_refresh_tokens (refresh_token TEXT, client_id TEXT, user_id TEXT, expires DATETIME, scope TEXT) ' );
230232 $ pdo ->exec ('CREATE TABLE oauth_scopes (scope TEXT, is_default BOOLEAN) ' );
231233 $ pdo ->exec ('CREATE TABLE oauth_public_keys (client_id TEXT, public_key TEXT, private_key TEXT, encryption_algorithm VARCHAR(100) DEFAULT "RS256") ' );
234+ $ pdo ->exec ('CREATE TABLE oauth_jwt (client_id VARCHAR(80), subject VARCHAR(80), public_key VARCHAR(2000)) ' );
232235
233236 // set up scopes
234237 foreach (explode (' ' , 'supportedscope1 supportedscope2 supportedscope3 supportedscope4 clientscope1 clientscope2 clientscope3 ' ) as $ supportedScope ) {
@@ -251,7 +254,8 @@ public function runPdoSql(\PDO $pdo)
251254 $ pdo ->exec ('INSERT INTO oauth_users (username, password) VALUES ("testuser", "password") ' );
252255 $ pdo ->exec ('INSERT INTO oauth_public_keys (client_id, public_key, private_key, encryption_algorithm) VALUES ("ClientID_One", "client_1_public", "client_1_private", "RS256") ' );
253256 $ pdo ->exec ('INSERT INTO oauth_public_keys (client_id, public_key, private_key, encryption_algorithm) VALUES ("ClientID_Two", "client_2_public", "client_2_private", "RS256") ' );
254- $ pdo ->exec (sprintf ('INSERT INTO oauth_public_keys (client_id, public_key, private_key, encryption_algorithm) VALUES (NULL, "%s", "%s", "RS256") ' , file_get_contents ($ this ->configDir .'/keys/id_rsa.pub ' ), file_get_contents ($ this ->configDir .'/keys/id_rsa ' )));
257+ $ pdo ->exec (sprintf ('INSERT INTO oauth_public_keys (client_id, public_key, private_key, encryption_algorithm) VALUES (NULL, "%s", "%s", "RS256") ' , $ this ->getTestPublicKey (), $ this ->getTestPrivateKey ()));
258+ $ pdo ->exec (sprintf ('INSERT INTO oauth_jwt (client_id, subject, public_key) VALUES ("oauth_test_client", "test_subject", "%s") ' , $ this ->getTestPublicKey ()));
255259 }
256260
257261 public function removeMysqlDb (\PDO $ pdo )
@@ -271,10 +275,33 @@ public function getConfigDir()
271275
272276 private function createMongoDb (\MongoDB $ db )
273277 {
274- $ db ->oauth_clients ->insert (array ('client_id ' => "oauth_test_client " , 'client_secret ' => "testpass " , 'redirect_uri ' => "http://example.com " , 'grant_types ' => 'implicit password ' ));
275- $ db ->oauth_access_tokens ->insert (array ('access_token ' => "testtoken " , 'client_id ' => "Some Client " ));
276- $ db ->oauth_authorization_codes ->insert (array ('authorization_code ' => "testcode " , 'client_id ' => "Some Client " ));
277- $ db ->oauth_users ->insert (array ('username ' => "testuser " , 'password ' => "password " ));
278+ $ db ->oauth_clients ->insert (array (
279+ 'client_id ' => "oauth_test_client " ,
280+ 'client_secret ' => "testpass " ,
281+ 'redirect_uri ' => "http://example.com " ,
282+ 'grant_types ' => 'implicit password '
283+ ));
284+
285+ $ db ->oauth_access_tokens ->insert (array (
286+ 'access_token ' => "testtoken " ,
287+ 'client_id ' => "Some Client "
288+ ));
289+
290+ $ db ->oauth_authorization_codes ->insert (array (
291+ 'authorization_code ' => "testcode " ,
292+ 'client_id ' => "Some Client "
293+ ));
294+
295+ $ db ->oauth_users ->insert (array (
296+ 'username ' => "testuser " ,
297+ 'password ' => "password "
298+ ));
299+
300+ $ db ->oauth_jwt ->insert (array (
301+ 'client_id ' => 'oauth_test_client ' ,
302+ 'key ' => $ this ->getTestPublicKey (),
303+ 'subject ' => 'test_subject ' ,
304+ ));
278305 }
279306
280307 private function createRedisDb (Redis $ storage )
@@ -298,10 +325,22 @@ private function createRedisDb(Redis $storage)
298325
299326 $ storage ->setScope ('clientscope1 clientscope2 clientscope3 ' , 'Test Default Scope Client ID 2 ' );
300327 $ storage ->setScope ('clientscope3 ' , 'Test Default Scope Client ID 2 ' , 'default ' );
328+
329+ $ storage ->setClientKey ('oauth_test_client ' , $ this ->getTestPublicKey (), 'test_subject ' );
301330 }
302331
303332 public function removeMongoDb (\MongoDB $ db )
304333 {
305334 $ db ->drop ();
306335 }
336+
337+ public function getTestPublicKey ()
338+ {
339+ return file_get_contents (__DIR__ .'/../../../config/keys/id_rsa.pub ' );
340+ }
341+
342+ private function getTestPrivateKey ()
343+ {
344+ return file_get_contents (__DIR__ .'/../../../config/keys/id_rsa ' );
345+ }
307346}
0 commit comments