5
5
use Closure ;
6
6
use Illuminate \Auth \AuthenticationException ;
7
7
use Laravel \Passport \Exceptions \MissingScopeException ;
8
- use Laravel \Passport \TokenRepository ;
8
+ use Laravel \Passport \ClientRepository ;
9
9
use League \OAuth2 \Server \Exception \OAuthServerException ;
10
10
use League \OAuth2 \Server \ResourceServer ;
11
11
use Symfony \Bridge \PsrHttpMessage \Factory \PsrHttpFactory ;
@@ -24,20 +24,20 @@ class CheckClientCredentials
24
24
protected $ server ;
25
25
26
26
/**
27
- * Token Repository.
27
+ * Client Repository.
28
28
*
29
- * @var \Laravel\Passport\TokenRepository
29
+ * @var \Laravel\Passport\ClientRepository
30
30
*/
31
31
protected $ repository ;
32
32
33
33
/**
34
34
* Create a new middleware instance.
35
35
*
36
36
* @param \League\OAuth2\Server\ResourceServer $server
37
- * @param \Laravel\Passport\TokenRepository $repository
37
+ * @param \Laravel\Passport\ClientRepository $repository
38
38
* @return void
39
39
*/
40
- public function __construct (ResourceServer $ server , TokenRepository $ repository )
40
+ public function __construct (ResourceServer $ server , ClientRepository $ repository )
41
41
{
42
42
$ this ->server = $ server ;
43
43
$ this ->repository = $ repository ;
@@ -82,18 +82,18 @@ public function handle($request, Closure $next, ...$scopes)
82
82
*/
83
83
protected function validate ($ psr , $ scopes )
84
84
{
85
- $ token = $ this ->repository ->find ($ psr ->getAttribute ('oauth_access_token_id ' ));
85
+ $ client = $ this ->repository ->find ($ psr ->getAttribute ('oauth_client_id ' ));
86
86
87
- if (! $ token || $ token -> client ->firstParty ()) {
87
+ if (! $ client || $ client ->firstParty ()) {
88
88
throw new AuthenticationException ;
89
89
}
90
90
91
- if (in_array ('* ' , $ token -> scopes )) {
91
+ if (in_array ('* ' , $ tokenScopes = $ psr -> getAttribute ( ' oauth_scopes ' ) )) {
92
92
return ;
93
93
}
94
94
95
95
foreach ($ scopes as $ scope ) {
96
- if ($ token -> cant ($ scope )) {
96
+ if (! in_array ($ scope, $ tokenScopes )) {
97
97
throw new MissingScopeException ($ scope );
98
98
}
99
99
}
0 commit comments