Skip to content

Commit 6457deb

Browse files
committed
CookieIdentity WIP
1 parent e1a609c commit 6457deb

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

Diff for: src/Bridges/SecurityHttp/CookieIdentity.php

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
3+
/**
4+
* This file is part of the Nette Framework (https://nette.org)
5+
* Copyright (c) 2004 David Grudl (https://davidgrudl.com)
6+
*/
7+
8+
declare(strict_types=1);
9+
10+
namespace Nette\Bridges\SecurityHttp;
11+
12+
use Nette;
13+
use Nette\Security\IIdentity;
14+
15+
16+
/**
17+
* Identity used by CookieStorage
18+
*/
19+
final class CookieIdentity implements IIdentity
20+
{
21+
private const MIN_LENGTH = 13;
22+
23+
private string $uid;
24+
25+
26+
public function __construct(string $uid)
27+
{
28+
if (strlen($uid) < self::MIN_LENGTH) {
29+
throw new \LogicException('UID is too short.');
30+
}
31+
$this->uid = $uid;
32+
}
33+
34+
35+
public function getId(): string
36+
{
37+
return $this->uid;
38+
}
39+
40+
41+
public function getRoles(): array
42+
{
43+
throw new Nette\NotSupportedException;
44+
}
45+
46+
47+
public function getData(): array
48+
{
49+
throw new Nette\NotSupportedException;
50+
}
51+
}

0 commit comments

Comments
 (0)