Skip to content

Commit 608bd7e

Browse files
use from #64
1 parent fe67a06 commit 608bd7e

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/Controller/AuthorizeController.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
use Psr\Http\Message\ResponseInterface;
66
use Psr\Http\Message\ServerRequestInterface;
77

8+
use Lcobucci\JWT\Configuration;
9+
use Lcobucci\JWT\Signer\Key\InMemory;
10+
use Lcobucci\JWT\Signer\Rsa\Sha256;
11+
812
class AuthorizeController extends ServerController
913
{
1014
final public function __invoke(ServerRequestInterface $request, array $args): ResponseInterface
@@ -21,11 +25,11 @@ final public function __invoke(ServerRequestInterface $request, array $args): Re
2125

2226
$queryParams = $request->getQueryParams();
2327

24-
$parser = new \Lcobucci\JWT\Parser();
28+
$jwtConfig = Configuration::forSymmetricSigner(new Sha256(), InMemory::plainText($this->config->getPrivateKey()));
2529

2630
try {
27-
$token = $parser->parse($request->getQueryParams()['request']);
28-
$_SESSION["nonce"] = $token->getClaim('nonce');
31+
$token = $jwtConfig->parser()->parse($request->getQueryParams()['request']);
32+
$_SESSION["nonce"] = $token->claims()->get('nonce');
2933
} catch(\Exception $e) {
3034
$_SESSION["nonce"] = $request->getQueryParams()['nonce'];
3135
}
@@ -42,7 +46,7 @@ final public function __invoke(ServerRequestInterface $request, array $args): Re
4246

4347
if (!isset($getVars['redirect_uri'])) {
4448
try {
45-
$getVars['redirect_uri'] = $token->getClaim("redirect_uri");
49+
$getVars['redirect_uri'] = $token->claims()->get("redirect_uri");
4650
} catch(\Exception $e) {
4751
return $this->getResponse()
4852
->withStatus(400, "Bad request, missing redirect uri")

0 commit comments

Comments
 (0)