-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[shopsys] refresh tokens for FE API (#1736)
[shopsys] refresh tokens for FE API (#1736)
- Loading branch information
1 parent
dec2abd
commit 5cb6656
Showing
16 changed files
with
430 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Shopsys\FrameworkBundle\Migrations; | ||
|
||
use Doctrine\DBAL\Schema\Schema; | ||
use Shopsys\MigrationBundle\Component\Doctrine\Migrations\AbstractMigration; | ||
|
||
class Version20200327080840 extends AbstractMigration | ||
{ | ||
/** | ||
* @param \Doctrine\DBAL\Schema\Schema $schema | ||
*/ | ||
public function up(Schema $schema): void | ||
{ | ||
$this->sql(' | ||
CREATE TABLE customer_user_refresh_token_chain ( | ||
uuid UUID NOT NULL, | ||
customer_user_id INT NOT NULL, | ||
token_chain VARCHAR(255) NOT NULL, | ||
expired_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, | ||
PRIMARY KEY(uuid) | ||
)'); | ||
$this->sql('CREATE INDEX IDX_DA9A5BFDBBB3772B ON customer_user_refresh_token_chain (customer_user_id)'); | ||
$this->sql(' | ||
ALTER TABLE | ||
customer_user_refresh_token_chain | ||
ADD | ||
CONSTRAINT FK_DA9A5BFDBBB3772B FOREIGN KEY (customer_user_id) REFERENCES customer_users (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); | ||
} | ||
|
||
/** | ||
* @param \Doctrine\DBAL\Schema\Schema $schema | ||
*/ | ||
public function down(Schema $schema): void | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Shopsys\FrameworkBundle\Model\Customer\User; | ||
|
||
use Doctrine\ORM\Mapping as ORM; | ||
use Ramsey\Uuid\Uuid; | ||
|
||
/** | ||
* @ORM\Table(name="customer_user_refresh_token_chain") | ||
* @ORM\Entity | ||
*/ | ||
class CustomerUserRefreshTokenChain | ||
{ | ||
/** | ||
* @var string | ||
* | ||
* @ORM\Id | ||
* @ORM\Column(type="guid", unique=true) | ||
*/ | ||
protected $uuid; | ||
|
||
/** | ||
* @var \Shopsys\FrameworkBundle\Model\Customer\User\CustomerUser | ||
* | ||
* @ORM\ManyToOne(targetEntity="Shopsys\FrameworkBundle\Model\Customer\User\CustomerUser", inversedBy="refreshTokenChain") | ||
* @ORM\JoinColumn(nullable=false) | ||
*/ | ||
protected $customerUser; | ||
|
||
/** | ||
* @var string | ||
* | ||
* @ORM\Column(type="string", nullable=false) | ||
*/ | ||
protected $tokenChain; | ||
|
||
/** | ||
* @var \DateTime | ||
* | ||
* @ORM\Column(type="datetime") | ||
*/ | ||
protected $expiredAt; | ||
|
||
/** | ||
* @param \Shopsys\FrameworkBundle\Model\Customer\User\CustomerUserRefreshTokenChainData $customerUserRefreshTokenChainData | ||
*/ | ||
public function __construct(CustomerUserRefreshTokenChainData $customerUserRefreshTokenChainData) | ||
{ | ||
$this->uuid = $customerUserRefreshTokenChainData->uuid ?: Uuid::uuid4()->toString(); | ||
$this->customerUser = $customerUserRefreshTokenChainData->customerUser; | ||
$this->tokenChain = $customerUserRefreshTokenChainData->tokenChain; | ||
$this->expiredAt = $customerUserRefreshTokenChainData->expiredAt; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getTokenChain(): string | ||
{ | ||
return $this->tokenChain; | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/Model/Customer/User/CustomerUserRefreshTokenChainData.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Shopsys\FrameworkBundle\Model\Customer\User; | ||
|
||
class CustomerUserRefreshTokenChainData | ||
{ | ||
/** | ||
* @var string|null | ||
*/ | ||
public $uuid; | ||
|
||
/** | ||
* @var \Shopsys\FrameworkBundle\Model\Customer\User\CustomerUser|null | ||
*/ | ||
public $customerUser; | ||
|
||
/** | ||
* @var string|null | ||
*/ | ||
public $tokenChain; | ||
|
||
/** | ||
* @var \DateTime|null | ||
*/ | ||
public $expiredAt; | ||
} |
16 changes: 16 additions & 0 deletions
16
src/Model/Customer/User/CustomerUserRefreshTokenChainDataFactory.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Shopsys\FrameworkBundle\Model\Customer\User; | ||
|
||
class CustomerUserRefreshTokenChainDataFactory implements CustomerUserRefreshTokenChainDataFactoryInterface | ||
{ | ||
/** | ||
* @return \Shopsys\FrameworkBundle\Model\Customer\User\CustomerUserRefreshTokenChainData | ||
*/ | ||
public function create(): CustomerUserRefreshTokenChainData | ||
{ | ||
return new CustomerUserRefreshTokenChainData(); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/Model/Customer/User/CustomerUserRefreshTokenChainDataFactoryInterface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
namespace Shopsys\FrameworkBundle\Model\Customer\User; | ||
|
||
interface CustomerUserRefreshTokenChainDataFactoryInterface | ||
{ | ||
/** | ||
* @return \Shopsys\FrameworkBundle\Model\Customer\User\CustomerUserRefreshTokenChainData | ||
*/ | ||
public function create(): CustomerUserRefreshTokenChainData; | ||
} |
Oops, something went wrong.