1 | <?php |
||
19 | class Middleware extends MiddlewareStack |
||
20 | { |
||
21 | protected $isGuarded; |
||
22 | protected $tokenService; |
||
23 | |||
24 | /** |
||
25 | * Create a new Middleware. |
||
26 | * |
||
27 | * @param TokenServiceInterface $tokenService A token service. |
||
28 | */ |
||
29 | public function __construct(TokenServiceInterface $tokenService) |
||
35 | |||
36 | /** |
||
37 | * Create a new Middleware. |
||
38 | * |
||
39 | * @param string $key Shared secret key used for generating token signatures. |
||
40 | * @param int $ttl Default Time to Live in seconds used for calculating the expiration time of the tokens (1440sec === 24min === default of session.gc_maxlifetime). |
||
41 | * @param string $algo Name of hashing algorithm. See hash_algos() for a list of supported algorithms. |
||
42 | * |
||
43 | * @return static |
||
44 | */ |
||
45 | public static function create($key, $ttl = 1440, $algo = 'SHA512') |
||
49 | |||
50 | /** |
||
51 | * Get the token service. |
||
52 | * |
||
53 | * @return TokenServiceInterface |
||
54 | */ |
||
55 | public function getTokenService() |
||
59 | |||
60 | /** |
||
61 | * Push a middleware onto the top of a new Stack instance. |
||
62 | * |
||
63 | * @param callable $newTopMiddleware the middleware to be pushed onto the top. |
||
64 | * |
||
65 | * @return static the new instance |
||
66 | */ |
||
67 | public function add(callable $newTopMiddleware) |
||
82 | |||
83 | /** |
||
84 | * Add new Guard middleware. |
||
85 | * |
||
86 | * @param callable $rejectMiddleware Defaults to `new Reject()`. |
||
87 | * |
||
88 | * @return static |
||
89 | */ |
||
90 | public function withGuard(callable $rejectMiddleware = null) |
||
94 | |||
95 | /** |
||
96 | * Add new AcceptHeaderToken middleware. |
||
97 | * |
||
98 | * @param string $headerName Header field name. |
||
99 | * |
||
100 | * @return static |
||
101 | */ |
||
102 | public function withAcceptHeaderToken($headerName = 'X-XSRF-TOKEN') |
||
106 | |||
107 | /** |
||
108 | * Add new AcceptMethods middleware. |
||
109 | * |
||
110 | * @param string[] $methods HTTP methods allowed to bypass CSRF protection. |
||
111 | * |
||
112 | * @return static |
||
113 | */ |
||
114 | public function withAcceptMethods(array $methods = array('GET', 'OPTIONS')) |
||
118 | |||
119 | /** |
||
120 | * Add new AcceptParsedBodyToken middleware. |
||
121 | * |
||
122 | * @param string|int|mixed[] $path <a href="https://github.com/schnittstabil/get" target="_blank">See `Get::value` for details</a> |
||
123 | * |
||
124 | * @return static |
||
125 | */ |
||
126 | public function withAcceptParsedBodyToken($path = 'X-XSRF-TOKEN') |
||
130 | |||
131 | /** |
||
132 | * Add new RespondWithCookieToken middleware. |
||
133 | * |
||
134 | * @param string $cookieName Cookie name. |
||
135 | * @param callable $modify Allows to modify the cookie; same signature as `$this->modifyCookie`. |
||
136 | * |
||
137 | * @return static |
||
138 | */ |
||
139 | public function withRespondWithCookieToken($cookieName = 'XSRF-TOKEN', callable $modify = null) |
||
143 | |||
144 | /** |
||
145 | * Add new RespondWithHeaderToken middleware. |
||
146 | * |
||
147 | * @param string $headerName Header field name. |
||
148 | * |
||
149 | * @return static |
||
150 | */ |
||
151 | public function withRespondWithHeaderToken($headerName = 'XSRF-TOKEN') |
||
155 | } |
||
156 |