Skip to content

Commit 20021d8

Browse files
author
Luca Degasperi
committed
Changed the client id from integer to varchar as per #6, updated the configuration documentation as suggested in #7
1 parent a8cd83f commit 20021d8

7 files changed

+61
-7
lines changed

src/config/oauth2.php

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,26 @@
99
|
1010
| Your OAuth2 Server can issue an access token based on different grant types
1111
| you can even provide your own grant type.
12+
| To choose which grant type suits your scenario, see
13+
| https://github.com/php-loep/oauth2-server/wiki/Which-OAuth-2.0-grant-should-I-use%3F
14+
|
1215
| Available grant types are:
1316
|
1417
| 'grant_types' => array(
1518
|
1619
| 'authorization_code' => array(
1720
| 'class' => 'League\OAuth2\Server\Grant\AuthCode',
1821
| 'access_token_ttl' => 3600,
22+
|
23+
| // the authorization code time to live
1924
| 'auth_token_ttl' => 3600,
2025
| ),
2126
|
2227
| 'password' => array(
2328
| 'class' => 'League\OAuth2\Server\Grant\Password',
2429
| 'access_token_ttl' => 604800,
30+
|
31+
| // the code to run in order to verify the user's identity
2532
| 'callback' => function($username, $password){
2633
|
2734
| return Auth::validate(array(
@@ -31,16 +38,26 @@
3138
| }
3239
| ),
3340
|
41+
| 'client_credentials' => array(
42+
| 'class' => 'League\OAuth2\Server\Grant\ClientCredentials',
43+
| 'access_token_ttl' => 3600,
44+
| ),
45+
|
3446
| 'refresh_token' => array(
3547
| 'class' => 'League\OAuth2\Server\Grant\RefreshToken',
3648
| 'access_token_ttl' => 3600,
49+
|
50+
| // the refresh token time to live
3751
| 'refresh_token_ttl' => 604800,
52+
|
53+
| // whether or not to issue a new refresh token when a new access token is issued
3854
| 'rotate_refresh_tokens' => false,
3955
| ),
4056
|
4157
| ),
4258
|
4359
*/
60+
4461
'grant_types' => array(
4562

4663
'authorization_code' => array(
@@ -116,16 +133,52 @@
116133
|--------------------------------------------------------------------------
117134
|
118135
| For how long the issued access token is valid (in seconds)
136+
| this can be also set on a per grant-type basis
119137
|
120138
*/
121139
'access_token_ttl' => 3600,
122140

123-
141+
/*
142+
|--------------------------------------------------------------------------
143+
| Limit clients to specific grants
144+
|--------------------------------------------------------------------------
145+
|
146+
| Whether or not to limit clients to specific grant types
147+
| This is useful to allow only trusted clients to access your API differently
148+
|
149+
*/
124150
'limit_clients_to_grants' => false,
125151

152+
/*
153+
|--------------------------------------------------------------------------
154+
| Limit clients to specific scopes
155+
|--------------------------------------------------------------------------
156+
|
157+
| Whether or not to limit clients to specific scopes
158+
| This is useful to only allow specific clients to use some scopes
159+
|
160+
*/
126161
'limit_clients_to_scopes' => false,
127162

163+
/*
164+
|--------------------------------------------------------------------------
165+
| Limit scopes to specific grants
166+
|--------------------------------------------------------------------------
167+
|
168+
| Whether or not to limit scopes to specific grants
169+
| This is useful to allow certain scopes to be used only with certain grant types
170+
|
171+
*/
128172
'limit_scopes_to_grants' => false,
129173

174+
/*
175+
|--------------------------------------------------------------------------
176+
| HTTP Header Only
177+
|--------------------------------------------------------------------------
178+
|
179+
| This will tell the resource server where to check for the access_token.
180+
| By default it checks both the query string and the http headers
181+
|
182+
*/
130183
'http_headers_only' => false,
131184
);

src/migrations/2013_07_24_132419_create_oauth_clients_table.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@ class CreateOAuthClientsTable extends Migration {
1313
public function up()
1414
{
1515
Schema::create('oauth_clients', function(Blueprint $table) {
16-
$table->increments('id');
16+
$table->string('id', 40);
1717
$table->string('secret', 40);
1818
$table->string('name');
1919
$table->boolean('auto_approve')->default(false);
2020
$table->timestamps();
2121

22+
$table->unique('id');
2223
$table->unique(array('id', 'secret'));
2324
});
2425
}

src/migrations/2013_07_24_133032_create_oauth_client_endpoints_table.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public function up()
1414
{
1515
Schema::create('oauth_client_endpoints', function(Blueprint $table) {
1616
$table->increments('id');
17-
$table->integer('client_id')->unsigned();
17+
$table->string('client_id', 40);
1818
$table->string('redirect_uri');
1919

2020
$table->timestamps();

src/migrations/2013_07_24_133359_create_oauth_sessions_table.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public function up()
1414
{
1515
Schema::create('oauth_sessions', function(Blueprint $table) {
1616
$table->increments('id');
17-
$table->integer('client_id')->unsigned();
17+
$table->string('client_id', 40);
1818
$table->enum('owner_type', array('client', 'user'))->default('user');
1919
$table->string('owner_id');
2020
$table->timestamps();

src/migrations/2013_07_24_134700_create_oauth_session_refresh_tokens_table.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public function up()
1717
$table->integer('session_access_token_id')->unsigned()->primary();
1818
$table->string('refresh_token', 40);
1919
$table->integer('refresh_token_expires');
20-
$table->integer('client_id')->unsigned();
20+
$table->string('client_id', 40);
2121

2222
$table->timestamps();
2323

src/migrations/2013_08_07_112252_create_oauth_client_grants_table.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public function up()
1414
{
1515
Schema::create('oauth_client_grants', function(Blueprint $table) {
1616
$table->increments('id');
17-
$table->integer('client_id')->unsigned();
17+
$table->string('client_id', 40);
1818
$table->integer('grant_id')->unsigned();
1919
$table->timestamps();
2020

src/migrations/2013_08_07_183251_create_oauth_client_scopes_table.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public function up()
1414
{
1515
Schema::create('oauth_client_scopes', function(Blueprint $table) {
1616
$table->increments('id');
17-
$table->integer('client_id')->unsigned();
17+
$table->string('client_id', 40);
1818
$table->integer('scope_id')->unsigned();
1919

2020
$table->foreign('client_id')

0 commit comments

Comments
 (0)