Skip to content

Commit

Permalink
use from #64
Browse files Browse the repository at this point in the history
  • Loading branch information
michielbdejong committed Sep 1, 2023
1 parent fe67a06 commit 608bd7e
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/Controller/AuthorizeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;

use Lcobucci\JWT\Configuration;
use Lcobucci\JWT\Signer\Key\InMemory;
use Lcobucci\JWT\Signer\Rsa\Sha256;

class AuthorizeController extends ServerController
{
final public function __invoke(ServerRequestInterface $request, array $args): ResponseInterface
Expand All @@ -21,11 +25,11 @@ final public function __invoke(ServerRequestInterface $request, array $args): Re

$queryParams = $request->getQueryParams();

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

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

if (!isset($getVars['redirect_uri'])) {
try {
$getVars['redirect_uri'] = $token->getClaim("redirect_uri");
$getVars['redirect_uri'] = $token->claims()->get("redirect_uri");
} catch(\Exception $e) {
return $this->getResponse()
->withStatus(400, "Bad request, missing redirect uri")
Expand Down

0 comments on commit 608bd7e

Please sign in to comment.