From 0f8268c93e6210d368f9dcd1900274871a9eacdf Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Sun, 30 Apr 2017 09:16:55 +0200 Subject: Add client_credentials as grant_type Therefore, username and password are no longer needed Signed-off-by: Thomas Citharel Allow to have global clients, auth through direct token or auth code and bring scopes Signed-off-by: Thomas Citharel fix review Signed-off-by: Thomas Citharel remove redirect uri requirement on specific clients add back password and depreciate it enforce state Signed-off-by: Thomas Citharel Allow apps to register themselves A handful of changes Signed-off-by: Thomas Citharel change timeout values Signed-off-by: Thomas Citharel set access_token lifetime to 1 year and double for refresh_token Signed-off-by: Thomas Citharel --- src/Wallabag/ApiBundle/Entity/Client.php | 87 +++++++++++++++++++++++++++++++- 1 file changed, 85 insertions(+), 2 deletions(-) (limited to 'src/Wallabag/ApiBundle/Entity/Client.php') diff --git a/src/Wallabag/ApiBundle/Entity/Client.php b/src/Wallabag/ApiBundle/Entity/Client.php index c15fd3fa..24444c9f 100644 --- a/src/Wallabag/ApiBundle/Entity/Client.php +++ b/src/Wallabag/ApiBundle/Entity/Client.php @@ -8,6 +8,7 @@ use Wallabag\UserBundle\Entity\User; use JMS\Serializer\Annotation\Groups; use JMS\Serializer\Annotation\SerializedName; use JMS\Serializer\Annotation\VirtualProperty; +use Symfony\Component\Validator\Constraints as Assert; /** * @ORM\Table("oauth2_clients") @@ -51,13 +52,39 @@ class Client extends BaseClient /** * @ORM\ManyToOne(targetEntity="Wallabag\UserBundle\Entity\User", inversedBy="clients") + * @ORM\JoinColumn(name="user_id", referencedColumnName="id", nullable=true) */ private $user; - public function __construct(User $user) + /** + * @ORM\Column(type="string", nullable=true) + */ + private $image; + + /** + * @ORM\Column(type="string", nullable=true) + */ + private $description; + + /** + * @ORM\Column(type="string", nullable=true) + */ + private $appUrl; + + /** + * @ORM\Column(type="datetime", nullable=true) + */ + private $createdAt; + + /** + * Client constructor. + * @param User|null $user + */ + public function __construct(User $user = null) { parent::__construct(); $this->user = $user; + $this->createdAt = new \DateTime(); } /** @@ -99,6 +126,62 @@ class Client extends BaseClient */ public function getClientId() { - return $this->getId().'_'.$this->getRandomId(); + return $this->getId() . '_' . $this->getRandomId(); + } + + /** + * @return string + */ + public function getImage() + { + return $this->image; + } + + /** + * @param string $image + */ + public function setImage($image) + { + $this->image = $image; + } + + /** + * @return string + */ + public function getDescription() + { + return $this->description; + } + + /** + * @param string $description + */ + public function setDescription($description) + { + $this->description = $description; + } + + /** + * @return string + */ + public function getAppUrl() + { + return $this->appUrl; + } + + /** + * @param string $appUrl + */ + public function setAppUrl($appUrl) + { + $this->appUrl = $appUrl; + } + + /** + * @return \DateTime + */ + public function getCreatedAt() + { + return $this->createdAt; } } -- cgit v1.2.3