| @@ 143-165 (lines=23) @@ | ||
| 140 | } |
|
| 141 | ||
| 142 | ||
| 143 | private function checkCookieExpireTime(Entity\CookieIdentity $identity) |
|
| 144 | { |
|
| 145 | if ($identity->getExpiresOn() < time()) { |
|
| 146 | $identity->setStatus(Entity\Identity::STATUS_EXPIRED); |
|
| 147 | ||
| 148 | $this->logger->info('cookie expired', [ |
|
| 149 | 'input' => [ |
|
| 150 | 'account' => $identity->getAccountId(), |
|
| 151 | 'series' => $identity->getSeries(), |
|
| 152 | 'key' => $identity->getKey(), |
|
| 153 | ], |
|
| 154 | 'user' => [ |
|
| 155 | 'account' => $identity->getAccountId(), |
|
| 156 | 'identity' => $identity->getId(), |
|
| 157 | ], |
|
| 158 | ]); |
|
| 159 | ||
| 160 | $mapper = $this->mapperFactory->create(Mapper\CookieIdentity::class); |
|
| 161 | $mapper->store($identity); |
|
| 162 | ||
| 163 | throw new IdentityExpired; |
|
| 164 | } |
|
| 165 | } |
|
| 166 | ||
| 167 | ||
| 168 | /** |
|
| @@ 175-199 (lines=25) @@ | ||
| 172 | * @param string $key |
|
| 173 | * @throws \Palladium\Exception\CompromisedCookie if key does not match |
|
| 174 | */ |
|
| 175 | private function checkCookieKey(Entity\CookieIdentity $identity, $key) |
|
| 176 | { |
|
| 177 | if ($identity->matchKey($key) === true) { |
|
| 178 | return; |
|
| 179 | } |
|
| 180 | ||
| 181 | $identity->setStatus(Entity\Identity::STATUS_BLOCKED); |
|
| 182 | ||
| 183 | $mapper = $this->mapperFactory->create(Mapper\CookieIdentity::class); |
|
| 184 | $mapper->store($identity); |
|
| 185 | ||
| 186 | $this->logger->warning('compromised cookie', [ |
|
| 187 | 'input' => [ |
|
| 188 | 'account' => $identity->getAccountId(), |
|
| 189 | 'series' => $identity->getSeries(), |
|
| 190 | 'key' => $identity->getKey(), |
|
| 191 | ], |
|
| 192 | 'user' => [ |
|
| 193 | 'account' => $identity->getAccountId(), |
|
| 194 | 'identity' => $identity->getId(), |
|
| 195 | ], |
|
| 196 | ]); |
|
| 197 | ||
| 198 | throw new CompromisedCookie; |
|
| 199 | } |
|
| 200 | ||
| 201 | ||
| 202 | public function discardIdentityCollection(Entity\IdentityCollection $list) |
|