Skip to content

Commit a1c0821

Browse files
author
Luca Degasperi
committed
Adopted PSR-2 syntax
1 parent 0516173 commit a1c0821

27 files changed

+446
-442
lines changed

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
"phpunit/phpunit": "3.7.22",
2323
"mockery/mockery": ">=0.7.2",
2424
"league/phpunit-coverage-listener": "v1.1.2",
25-
"orchestra/testbench": "2.0.*"
25+
"orchestra/testbench": "2.0.*",
26+
"squizlabs/php_codesniffer": "1.*"
2627
},
2728
"autoload": {
2829
"classmap": [

src/LucaDegasperi/OAuth2Server/Facades/AuthorizationServerFacade.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22

33
use Illuminate\Support\Facades\Facade;
44

5-
class AuthorizationServerFacade extends Facade {
5+
class AuthorizationServerFacade extends Facade
6+
{
67

78
/**
89
* @codeCoverageIgnore
910
*/
10-
protected static function getFacadeAccessor() { return 'oauth2.authorization-server'; }
11+
protected static function getFacadeAccessor()
12+
{
13+
return 'oauth2.authorization-server';
14+
}
1115
}
12-
13-

src/LucaDegasperi/OAuth2Server/Facades/ResourceServerFacade.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22

33
use Illuminate\Support\Facades\Facade;
44

5-
class ResourceServerFacade extends Facade {
5+
class ResourceServerFacade extends Facade
6+
{
67

78
/**
89
* @codeCoverageIgnore
910
*/
10-
protected static function getFacadeAccessor() { return 'oauth2.resource-server'; }
11-
11+
protected static function getFacadeAccessor()
12+
{
13+
return 'oauth2.resource-server';
14+
}
1215
}
13-
14-

src/LucaDegasperi/OAuth2Server/Filters/CheckAuthorizationParamsFilter.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
use League\OAuth2\Server\Exception\ClientException;
77
use Exception;
88

9-
class CheckAuthorizationParamsFilter {
9+
class CheckAuthorizationParamsFilter
10+
{
1011

1112
public function filter($route, $request, $scope = null)
1213
{
@@ -34,4 +35,4 @@ public function filter($route, $request, $scope = null)
3435
), 500);
3536
}
3637
}
37-
}
38+
}

src/LucaDegasperi/OAuth2Server/Filters/OAuthFilter.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,26 @@
44
use Response;
55
use Config;
66

7-
class OAuthFilter {
7+
class OAuthFilter
8+
{
89

910
public function filter($route, $request, $scope = null)
1011
{
1112
try {
1213
ResourceServer::isValid(Config::get('oauth2-server-laravel::oauth2.http_headers_only'));
13-
}
14-
catch (\League\OAuth2\Server\Exception\InvalidAccessTokenException $e) {
14+
} catch (\League\OAuth2\Server\Exception\InvalidAccessTokenException $e) {
1515
return Response::json(array(
1616
'status' => 403,
1717
'error' => 'forbidden',
1818
'error_message' => $e->getMessage(),
1919
), 403);
2020
}
2121

22-
if ( ! is_null($scope)) {
22+
if (! is_null($scope)) {
2323
$scopes = explode(',', $scope);
2424

2525
foreach ($scopes as $s) {
26-
if ( ! ResourceServer::hasScope($s)) {
26+
if (! ResourceServer::hasScope($s)) {
2727
return Response::json(array(
2828
'status' => 403,
2929
'error' => 'forbidden',
@@ -33,5 +33,4 @@ public function filter($route, $request, $scope = null)
3333
}
3434
}
3535
}
36-
37-
}
36+
}

src/LucaDegasperi/OAuth2Server/Filters/OAuthOwnerFilter.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@
33
use ResourceServer;
44
use Response;
55

6-
class OAuthOwnerFilter {
6+
class OAuthOwnerFilter
7+
{
78

89
public function filter($route, $request, $scope = null)
910
{
10-
if ( ! is_null($scope) and ResourceServer::getOwnerType() !== $scope){
11+
if (! is_null($scope) and ResourceServer::getOwnerType() !== $scope) {
1112
return Response::json(array(
1213
'status' => 403,
1314
'error' => 'forbidden',
1415
'error_message' => 'Only access tokens representing '.$scope.' can use this endpoint',
1516
), 403);
1617
}
1718
}
18-
19-
}
19+
}

src/LucaDegasperi/OAuth2Server/OAuth2ServerServiceProvider.php

Lines changed: 72 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -3,98 +3,98 @@
33
use Illuminate\Support\ServiceProvider;
44
use LucaDegasperi\OAuth2Server\Proxies\AuthorizationServerProxy;
55

6-
class OAuth2ServerServiceProvider extends ServiceProvider {
6+
class OAuth2ServerServiceProvider extends ServiceProvider
7+
{
78

8-
/**
9-
* Indicates if loading of the provider is deferred.
10-
*
11-
* @var bool
12-
*/
13-
protected $defer = false;
9+
/**
10+
* Indicates if loading of the provider is deferred.
11+
*
12+
* @var bool
13+
*/
14+
protected $defer = false;
1415

15-
/**
16-
* Bootstrap the application events.
17-
*
18-
* @return void
19-
*/
20-
public function boot()
21-
{
22-
$this->package('lucadegasperi/oauth2-server-laravel');
16+
/**
17+
* Bootstrap the application events.
18+
*
19+
* @return void
20+
*/
21+
public function boot()
22+
{
23+
$this->package('lucadegasperi/oauth2-server-laravel');
2324

24-
require_once __DIR__.'/../../filters.php';
25-
}
25+
require_once __DIR__.'/../../filters.php';
26+
}
2627

27-
/**
28-
* Register the service provider.
29-
*
30-
* @return void
31-
*/
32-
public function register()
33-
{
34-
// let's bind the interfaces to the implementations
35-
$app = $this->app;
28+
/**
29+
* Register the service provider.
30+
*
31+
* @return void
32+
*/
33+
public function register()
34+
{
35+
// let's bind the interfaces to the implementations
36+
$app = $this->app;
3637

37-
$app->bind('League\OAuth2\Server\Storage\ClientInterface', 'LucaDegasperi\OAuth2Server\Repositories\FluentClient');
38-
$app->bind('League\OAuth2\Server\Storage\ScopeInterface', 'LucaDegasperi\OAuth2Server\Repositories\FluentScope');
39-
$app->bind('League\OAuth2\Server\Storage\SessionInterface', 'LucaDegasperi\OAuth2Server\Repositories\FluentSession');
38+
$app->bind('League\OAuth2\Server\Storage\ClientInterface', 'LucaDegasperi\OAuth2Server\Repositories\FluentClient');
39+
$app->bind('League\OAuth2\Server\Storage\ScopeInterface', 'LucaDegasperi\OAuth2Server\Repositories\FluentScope');
40+
$app->bind('League\OAuth2\Server\Storage\SessionInterface', 'LucaDegasperi\OAuth2Server\Repositories\FluentSession');
4041

41-
$app['oauth2.authorization-server'] = $app->share(function($app){
42+
$app['oauth2.authorization-server'] = $app->share(function ($app) {
4243

43-
$server = $app->make('League\OAuth2\Server\Authorization');
44+
$server = $app->make('League\OAuth2\Server\Authorization');
4445

45-
$config = $app['config']->get('oauth2-server-laravel::oauth2');
46+
$config = $app['config']->get('oauth2-server-laravel::oauth2');
4647

47-
// add the supported grant types to the authorization server
48-
foreach ($config['grant_types'] as $grantKey => $grantValue) {
48+
// add the supported grant types to the authorization server
49+
foreach ($config['grant_types'] as $grantKey => $grantValue) {
4950

50-
$server->addGrantType(new $grantValue['class']($server));
51-
$server->getGrantType($grantKey)->setAccessTokenTTL($grantValue['access_token_ttl']);
51+
$server->addGrantType(new $grantValue['class']($server));
52+
$server->getGrantType($grantKey)->setAccessTokenTTL($grantValue['access_token_ttl']);
5253

53-
if (array_key_exists('callback', $grantValue)) {
54-
$server->getGrantType($grantKey)->setVerifyCredentialsCallback($grantValue['callback']);
55-
}
56-
if (array_key_exists('auth_token_ttl', $grantValue)) {
57-
$server->getGrantType($grantKey)->setAuthTokenTTL($grantValue['auth_token_ttl']);
58-
}
59-
if (array_key_exists('refresh_token_ttl', $grantValue)) {
60-
$server->getGrantType($grantKey)->setRefreshTokenTTL($grantValue['refresh_token_ttl']);
61-
}
62-
if (array_key_exists('rotate_refresh_tokens', $grantValue)) {
63-
$server->getGrantType($grantKey)->rotateRefreshTokens($grantValue['rotate_refresh_tokens']);
64-
}
65-
}
54+
if (array_key_exists('callback', $grantValue)) {
55+
$server->getGrantType($grantKey)->setVerifyCredentialsCallback($grantValue['callback']);
56+
}
57+
if (array_key_exists('auth_token_ttl', $grantValue)) {
58+
$server->getGrantType($grantKey)->setAuthTokenTTL($grantValue['auth_token_ttl']);
59+
}
60+
if (array_key_exists('refresh_token_ttl', $grantValue)) {
61+
$server->getGrantType($grantKey)->setRefreshTokenTTL($grantValue['refresh_token_ttl']);
62+
}
63+
if (array_key_exists('rotate_refresh_tokens', $grantValue)) {
64+
$server->getGrantType($grantKey)->rotateRefreshTokens($grantValue['rotate_refresh_tokens']);
65+
}
66+
}
6667

67-
$server->requireStateParam($config['state_param']);
68+
$server->requireStateParam($config['state_param']);
6869

69-
$server->requireScopeParam($config['scope_param']);
70+
$server->requireScopeParam($config['scope_param']);
7071

71-
$server->setScopeDelimeter($config['scope_delimiter']);
72+
$server->setScopeDelimeter($config['scope_delimiter']);
7273

73-
$server->setDefaultScope($config['default_scope']);
74+
$server->setDefaultScope($config['default_scope']);
7475

75-
$server->setAccessTokenTTL($config['access_token_ttl']);
76+
$server->setAccessTokenTTL($config['access_token_ttl']);
7677

77-
return new AuthorizationServerProxy($server);
78+
return new AuthorizationServerProxy($server);
7879

79-
});
80+
});
8081

81-
$app['oauth2.resource-server'] = $app->share(function($app){
82+
$app['oauth2.resource-server'] = $app->share(function ($app) {
8283

83-
$server = $app->make('League\OAuth2\Server\Resource');
84+
$server = $app->make('League\OAuth2\Server\Resource');
8485

85-
return $server;
86+
return $server;
8687

87-
});
88-
}
88+
});
89+
}
8990

90-
/**
91-
* Get the services provided by the provider.
92-
*
93-
* @return array
94-
*/
95-
public function provides()
96-
{
97-
return array('oauth2.authorization-server', 'oauth2.resource-server');
98-
}
99-
100-
}
91+
/**
92+
* Get the services provided by the provider.
93+
*
94+
* @return array
95+
*/
96+
public function provides()
97+
{
98+
return array('oauth2.authorization-server', 'oauth2.resource-server');
99+
}
100+
}

src/LucaDegasperi/OAuth2Server/Proxies/AuthorizationServerProxy.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
use Exception;
77
use Response;
88

9-
class AuthorizationServerProxy {
9+
class AuthorizationServerProxy
10+
{
1011

1112
protected $authServer;
1213

@@ -39,15 +40,15 @@ public function makeRedirect($uri, $params = array(), $queryDelimeter = '?')
3940
}
4041

4142
public function makeRedirectWithCode($code, $params = array())
42-
{
43+
{
4344
return $this->makeRedirect($params['redirect_uri'], array(
4445
'code' => $code,
4546
'state' => isset($params['state']) ? $params['state'] : '',
4647
));
4748
}
4849

4950
public function makeRedirectWithError($params = array())
50-
{
51+
{
5152
return $this->makeRedirect($params['redirect_uri'], array(
5253
'error' => 'access_denied',
5354
'error_message' => $this->authServer->getExceptionMessage('access_denied'),
@@ -101,5 +102,4 @@ public function performAccessTokenFlow()
101102

102103
return Response::json($response);
103104
}
104-
105-
}
105+
}

src/LucaDegasperi/OAuth2Server/Repositories/FluentClient.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,29 @@
44
use DB;
55
use Config;
66

7-
class FluentClient implements ClientInterface {
7+
class FluentClient implements ClientInterface
8+
{
89

910
public function getClient($clientId, $clientSecret = null, $redirectUri = null, $grantType = null)
1011
{
11-
if ( ! is_null($redirectUri) && is_null($clientSecret)) {
12+
if (! is_null($redirectUri) && is_null($clientSecret)) {
1213
$query = DB::table('oauth_clients')
1314
->join('oauth_client_endpoints', 'oauth_clients.id', '=', 'oauth_client_endpoints.client_id')
1415
->where('oauth_clients.id', $clientId)
1516
->where('oauth_client_endpoints.redirect_uri', $redirectUri);
16-
} elseif ( ! is_null($clientSecret) && is_null($redirectUri)) {
17+
} elseif (! is_null($clientSecret) && is_null($redirectUri)) {
1718
$query = DB::table('oauth_clients')
1819
->where('oauth_clients.id', $clientId)
1920
->where('oauth_clients.secret', $clientSecret);
20-
} elseif ( ! is_null($clientSecret) && ! is_null($redirectUri)) {
21+
} elseif (! is_null($clientSecret) && ! is_null($redirectUri)) {
2122
$query = DB::table('oauth_clients')
2223
->join('oauth_client_endpoints', 'oauth_clients.id', '=', 'oauth_client_endpoints.client_id')
2324
->where('oauth_clients.id', $clientId)
2425
->where('oauth_clients.secret', $clientSecret)
2526
->where('oauth_client_endpoints.redirect_uri', $redirectUri);
2627
}
2728

28-
if( Config::get('oauth2-server-laravel::oauth2.limit_clients_to_grants') === true and ! is_null($grantType)) {
29+
if (Config::get('oauth2-server-laravel::oauth2.limit_clients_to_grants') === true and ! is_null($grantType)) {
2930
$query = $query->join('oauth_client_grants', 'oauth_clients.id', '=', 'oauth_client_grants.client_id')
3031
->join('oauth_grants', 'oauth_grants.id', '=', 'oauth_client_grants.grant_id')
3132
->where('oauth_grants.grant', $grantType);
@@ -46,5 +47,4 @@ public function getClient($clientId, $clientSecret = null, $redirectUri = null,
4647
'name' => $result->name
4748
);
4849
}
49-
50-
}
50+
}

0 commit comments

Comments
 (0)