22
33namespace DesignMyNight \Mongodb \Passport ;
44
5- use Zend \Diactoros \Response ;
6- use Zend \Diactoros \ServerRequest ;
7- use Lcobucci \JWT \Parser as JwtParser ;
8- use League \OAuth2 \Server \AuthorizationServer ;
9- use \Laravel \Passport \ClientRepository ;
5+ use Laravel \Passport \ClientRepository ;
106use Laravel \Passport \PersonalAccessTokenResult ;
117use Laravel \Passport \TokenRepository ;
8+ use Laravel \Passport \Passport ;
9+ use Lcobucci \JWT \Parser as JwtParser ;
10+ use League \OAuth2 \Server \AuthorizationServer ;
11+ use Nyholm \Psr7 \Response ;
12+ use Nyholm \Psr7 \ServerRequest ;
13+ use Psr \Http \Message \ServerRequestInterface ;
1214
1315class PersonalAccessTokenFactory
1416{
@@ -37,6 +39,8 @@ class PersonalAccessTokenFactory
3739 * The JWT token parser instance.
3840 *
3941 * @var \Lcobucci\JWT\Parser
42+ *
43+ * @deprecated This property will be removed in a future Passport version.
4044 */
4145 protected $ jwt ;
4246
@@ -92,14 +96,16 @@ public function make($userId, $name, array $scopes = [])
9296 * @param \Laravel\Passport\Client $client
9397 * @param mixed $userId
9498 * @param array $scopes
95- * @return \Zend\Diactoros\ServerRequest
99+ * @return \Psr\Http\Message\ServerRequestInterface
96100 */
97101 protected function createRequest ($ client , $ userId , array $ scopes )
98102 {
103+ $ secret = Passport::$ hashesClientSecrets ? $ this ->clients ->getPersonalAccessClientSecret () : $ client ->secret ;
104+
99105 return (new ServerRequest )->withParsedBody ([
100106 'grant_type ' => 'personal_access ' ,
101107 'client_id ' => $ client ->id ,
102- 'client_secret ' => $ client -> secret ,
108+ 'client_secret ' => $ secret ,
103109 'user_id ' => $ userId ,
104110 'scope ' => implode (' ' , $ scopes ),
105111 ]);
@@ -108,10 +114,10 @@ protected function createRequest($client, $userId, array $scopes)
108114 /**
109115 * Dispatch the given request to the authorization server.
110116 *
111- * @param \Zend\Diactoros\ServerRequest $request
117+ * @param Psr\Http\Message\ServerRequestInterface $request
112118 * @return array
113119 */
114- protected function dispatchRequestToAuthorizationServer (ServerRequest $ request )
120+ protected function dispatchRequestToAuthorizationServer (ServerRequestInterface $ request )
115121 {
116122 return json_decode ($ this ->server ->respondToAccessTokenRequest (
117123 $ request , new Response
0 commit comments