diff options
author | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2015-01-31 15:14:10 +0100 |
---|---|---|
committer | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2015-01-31 15:14:10 +0100 |
commit | c3235553ddc2bb5965f6fe00e750cfe4aac9ccdf (patch) | |
tree | 271305a039d31059c7af8be220da08b9331baeec /src/Wallabag/CoreBundle/Entity | |
parent | 71691fe44a7b2a80f3b9d96d54720cce7994ad08 (diff) | |
download | wallabag-c3235553ddc2bb5965f6fe00e750cfe4aac9ccdf.tar.gz wallabag-c3235553ddc2bb5965f6fe00e750cfe4aac9ccdf.tar.zst wallabag-c3235553ddc2bb5965f6fe00e750cfe4aac9ccdf.zip |
first implementation of security
Diffstat (limited to 'src/Wallabag/CoreBundle/Entity')
-rw-r--r-- | src/Wallabag/CoreBundle/Entity/Entries.php | 1 | ||||
-rw-r--r-- | src/Wallabag/CoreBundle/Entity/Users.php | 87 |
2 files changed, 87 insertions, 1 deletions
diff --git a/src/Wallabag/CoreBundle/Entity/Entries.php b/src/Wallabag/CoreBundle/Entity/Entries.php index 712ff126..3c061a37 100644 --- a/src/Wallabag/CoreBundle/Entity/Entries.php +++ b/src/Wallabag/CoreBundle/Entity/Entries.php | |||
@@ -10,6 +10,7 @@ use Symfony\Component\Validator\Constraints as Assert; | |||
10 | * | 10 | * |
11 | * @ORM\Entity(repositoryClass="Wallabag\CoreBundle\Repository\EntriesRepository") | 11 | * @ORM\Entity(repositoryClass="Wallabag\CoreBundle\Repository\EntriesRepository") |
12 | * @ORM\Table(name="entries") | 12 | * @ORM\Table(name="entries") |
13 | * | ||
13 | */ | 14 | */ |
14 | class Entries | 15 | class Entries |
15 | { | 16 | { |
diff --git a/src/Wallabag/CoreBundle/Entity/Users.php b/src/Wallabag/CoreBundle/Entity/Users.php index 3db4a3fd..96867bd6 100644 --- a/src/Wallabag/CoreBundle/Entity/Users.php +++ b/src/Wallabag/CoreBundle/Entity/Users.php | |||
@@ -3,6 +3,9 @@ | |||
3 | namespace Wallabag\CoreBundle\Entity; | 3 | namespace Wallabag\CoreBundle\Entity; |
4 | 4 | ||
5 | use Doctrine\ORM\Mapping as ORM; | 5 | use Doctrine\ORM\Mapping as ORM; |
6 | use Symfony\Component\Security\Core\User\UserInterface; | ||
7 | use Symfony\Component\Security\Core\User\EquatableInterface; | ||
8 | use Symfony\Component\Security\Core\User\AdvancedUserInterface; | ||
6 | 9 | ||
7 | /** | 10 | /** |
8 | * Users | 11 | * Users |
@@ -10,7 +13,7 @@ use Doctrine\ORM\Mapping as ORM; | |||
10 | * @ORM\Table(name="users") | 13 | * @ORM\Table(name="users") |
11 | * @ORM\Entity | 14 | * @ORM\Entity |
12 | */ | 15 | */ |
13 | class Users | 16 | class Users implements AdvancedUserInterface, \Serializable |
14 | { | 17 | { |
15 | /** | 18 | /** |
16 | * @var integer | 19 | * @var integer |
@@ -29,6 +32,11 @@ class Users | |||
29 | private $username; | 32 | private $username; |
30 | 33 | ||
31 | /** | 34 | /** |
35 | * @ORM\Column(type="string", length=32) | ||
36 | */ | ||
37 | private $salt; | ||
38 | |||
39 | /** | ||
32 | * @var string | 40 | * @var string |
33 | * | 41 | * |
34 | * @ORM\Column(name="password", type="text", nullable=true) | 42 | * @ORM\Column(name="password", type="text", nullable=true) |
@@ -49,7 +57,16 @@ class Users | |||
49 | */ | 57 | */ |
50 | private $email; | 58 | private $email; |
51 | 59 | ||
60 | /** | ||
61 | * @ORM\Column(name="is_active", type="boolean") | ||
62 | */ | ||
63 | private $isActive; | ||
52 | 64 | ||
65 | public function __construct() | ||
66 | { | ||
67 | $this->isActive = true; | ||
68 | $this->salt = md5(uniqid(null, true)); | ||
69 | } | ||
53 | 70 | ||
54 | /** | 71 | /** |
55 | * Get id | 72 | * Get id |
@@ -85,6 +102,22 @@ class Users | |||
85 | } | 102 | } |
86 | 103 | ||
87 | /** | 104 | /** |
105 | * @inheritDoc | ||
106 | */ | ||
107 | public function getSalt() | ||
108 | { | ||
109 | return $this->salt; | ||
110 | } | ||
111 | |||
112 | /** | ||
113 | * @inheritDoc | ||
114 | */ | ||
115 | public function getRoles() | ||
116 | { | ||
117 | return array('ROLE_USER'); | ||
118 | } | ||
119 | |||
120 | /** | ||
88 | * Set password | 121 | * Set password |
89 | * | 122 | * |
90 | * @param string $password | 123 | * @param string $password |
@@ -152,4 +185,56 @@ class Users | |||
152 | { | 185 | { |
153 | return $this->email; | 186 | return $this->email; |
154 | } | 187 | } |
188 | |||
189 | /** | ||
190 | * @inheritDoc | ||
191 | */ | ||
192 | public function eraseCredentials() | ||
193 | { | ||
194 | } | ||
195 | |||
196 | /** | ||
197 | * @see \Serializable::serialize() | ||
198 | */ | ||
199 | public function serialize() | ||
200 | { | ||
201 | return serialize(array( | ||
202 | $this->id, | ||
203 | )); | ||
204 | } | ||
205 | |||
206 | /** | ||
207 | * @see \Serializable::unserialize() | ||
208 | */ | ||
209 | public function unserialize($serialized) | ||
210 | { | ||
211 | list ( | ||
212 | $this->id, | ||
213 | ) = unserialize($serialized); | ||
214 | } | ||
215 | |||
216 | public function isEqualTo(UserInterface $user) | ||
217 | { | ||
218 | return $this->username === $user->getUsername(); | ||
219 | } | ||
220 | |||
221 | public function isAccountNonExpired() | ||
222 | { | ||
223 | return true; | ||
224 | } | ||
225 | |||
226 | public function isAccountNonLocked() | ||
227 | { | ||
228 | return true; | ||
229 | } | ||
230 | |||
231 | public function isCredentialsNonExpired() | ||
232 | { | ||
233 | return true; | ||
234 | } | ||
235 | |||
236 | public function isEnabled() | ||
237 | { | ||
238 | return $this->isActive; | ||
239 | } | ||
155 | } | 240 | } |