Skip to content

Commit

Permalink
Merge pull request #58 from vippsas/publication-2.5.2
Browse files Browse the repository at this point in the history
VIPPS-456: Vipps Login Module wrong headers for Token request
  • Loading branch information
voleye authored Jun 20, 2024
2 parents 8ef5f8f + dd52358 commit fa1fad6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
21 changes: 17 additions & 4 deletions Gateway/Command/TokenCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,17 @@

namespace Vipps\Login\Gateway\Command;

use Firebase\JWT\JWT;
use Firebase\JWT\Key;
use Magento\Framework\App\ResourceConnection;
use Magento\Framework\Serialize\SerializerInterface;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\HTTP\ClientFactory;
use Magento\Framework\Serialize\SerializerInterface;
use Magento\Framework\UrlInterface;
use Psr\Log\LoggerInterface;
use Vipps\Login\Api\ApiEndpointsInterface;
use Vipps\Login\Api\ModuleMetadataInterface;
use Vipps\Login\Model\ConfigInterface;
use Psr\Log\LoggerInterface;
use Firebase\JWT\JWT;
use phpseclib3\Crypt\PublicKeyLoader;
use phpseclib3\Math\BigInteger;

Expand Down Expand Up @@ -77,6 +78,10 @@ class TokenCommand
* @var ResourceConnection
*/
private $resourceConnection;
/**
* @var ModuleMetadataInterface
*/
private $moduleMetadata;

/**
* @param ConfigInterface $config
Expand All @@ -86,6 +91,7 @@ class TokenCommand
* @param UrlInterface $url
* @param LoggerInterface $logger
* @param ResourceConnection $resourceConnection
* @param ModuleMetadataInterface $moduleMetadata
*/
public function __construct(
ConfigInterface $config,
Expand All @@ -94,7 +100,8 @@ public function __construct(
ClientFactory $httpClientFactory,
UrlInterface $url,
LoggerInterface $logger,
ResourceConnection $resourceConnection
ResourceConnection $resourceConnection,
ModuleMetadataInterface $moduleMetadata
) {
$this->config = $config;
$this->httpClientFactory = $httpClientFactory;
Expand All @@ -103,6 +110,7 @@ public function __construct(
$this->url = $url;
$this->logger = $logger;
$this->resourceConnection = $resourceConnection;
$this->moduleMetadata = $moduleMetadata;
}

/**
Expand Down Expand Up @@ -132,6 +140,11 @@ public function execute($code)
$httpClient->addHeader('Content-Type', 'application/x-www-form-urlencoded');
$httpClient->setCredentials($clientId, $clientSecret);

$httpClient->addHeader('Vipps-System-Name', $this->moduleMetadata->getSystemName());
$httpClient->addHeader('Vipps-System-Version', $this->moduleMetadata->getSystemVersion());
$httpClient->addHeader('Vipps-System-Plugin-Name', $this->moduleMetadata->getModuleName());
$httpClient->addHeader('Vipps-System-Plugin-Version', $this->moduleMetadata->getModuleVersion());

$httpClient->post($this->apiEndpoints->getTokenEndpoint(), [
'grant_type' => 'authorization_code',
'code' => $code,
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"psr/log": "^1.0||^2.0||^3.0"
},
"type": "magento2-module",
"version": "2.5.1",
"version": "2.5.2",
"license": [
"OSL-3.0",
"AFL-3.0"
Expand Down

0 comments on commit fa1fad6

Please sign in to comment.