Skip to content

Commit cbd78fe

Browse files
committed
adding client metadata table
1 parent 1ef0e74 commit cbd78fe

File tree

2 files changed

+57
-1
lines changed

2 files changed

+57
-1
lines changed

src/LucaDegasperi/OAuth2Server/Repositories/FluentClient.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,22 @@ public function getClient($clientId, $clientSecret = null, $redirectUri = null,
3939
return false;
4040
}
4141

42+
43+
44+
$rawMetadata = DB::table('oauth_client_metadata')->where('client_id', '=', $result->id)->get();
45+
46+
$metadata = array();
47+
48+
foreach ($rawMetadata as $meta) {
49+
$metadata[$meta->key] = $meta->value;
50+
}
51+
4252
return array(
4353
'client_id' => $result->id,
4454
'client_secret' => $result->secret,
4555
'redirect_uri' => (isset($result->redirect_uri)) ? $result->redirect_uri : null,
46-
'name' => $result->name
56+
'name' => $result->name,
57+
'metadata' => $metadata
4758
);
4859
}
4960
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
6+
class CreateOauthClientMetadataTable extends Migration
7+
{
8+
9+
/**
10+
* Run the migrations.
11+
*
12+
* @return void
13+
*/
14+
public function up()
15+
{
16+
Schema::create('oauth_client_metadata', function (Blueprint $table) {
17+
$table->increments('id');
18+
$table->integer('client_id')->unsigned();
19+
$table->string('key', 40);
20+
$table->string('value');
21+
$table->timestamps();
22+
23+
$table->foreign('client_id')
24+
->references('id')->on('oauth_clients')
25+
->onDelete('cascade');
26+
27+
$table->unique(array('client_id', 'key'));
28+
$table->index('client_id');
29+
30+
});
31+
}
32+
33+
/**
34+
* Reverse the migrations.
35+
*
36+
* @return void
37+
*/
38+
public function down()
39+
{
40+
Schema::table('oauth_client_metadata', function ($table) {
41+
$table->dropForeign('oauth_grant_scopes_client_id_foreign');
42+
});
43+
Schema::drop('oauth_client_metadata');
44+
}
45+
}

0 commit comments

Comments
 (0)