1 | <?php |
||
20 | class Middleware implements MiddlewareStackInterface |
||
21 | { |
||
22 | use CallableMiddlewareStackTrait; |
||
23 | |||
24 | protected $isGuarded; |
||
25 | protected $tokenService; |
||
26 | |||
27 | /** |
||
28 | * Create a new Middleware. |
||
29 | * |
||
30 | * @param TokenServiceInterface $tokenService A token service |
||
31 | */ |
||
32 | public function __construct(TokenServiceInterface $tokenService) |
||
37 | |||
38 | /** |
||
39 | * Get the token service. |
||
40 | * |
||
41 | * @return TokenServiceInterface |
||
42 | */ |
||
43 | public function getTokenService() |
||
47 | |||
48 | /** |
||
49 | * Push a middleware onto the top of a new Stack instance. |
||
50 | * |
||
51 | * @param callable $newTopMiddleware the middleware to be pushed onto the top |
||
52 | * |
||
53 | * @return static the new instance |
||
54 | * |
||
55 | * @SuppressWarnings(PHPMD.ElseExpression) |
||
56 | */ |
||
57 | public function add(callable $newTopMiddleware) |
||
74 | |||
75 | /** |
||
76 | * Add new Guard middleware. |
||
77 | * |
||
78 | * @param callable $rejectMiddleware Defaults to `new Reject()` |
||
79 | * |
||
80 | * @return static |
||
81 | */ |
||
82 | public function withGuard(callable $rejectMiddleware = null) |
||
86 | |||
87 | /** |
||
88 | * Add new AcceptHeaderToken middleware. |
||
89 | * |
||
90 | * @param string $headerName Header field name |
||
91 | * |
||
92 | * @return static |
||
93 | */ |
||
94 | public function withAcceptHeaderToken($headerName = 'X-XSRF-TOKEN') |
||
98 | |||
99 | /** |
||
100 | * Add new AcceptMethods middleware. |
||
101 | * |
||
102 | * @param string[] $methods HTTP methods allowed to bypass CSRF protection |
||
103 | * |
||
104 | * @return static |
||
105 | */ |
||
106 | public function withAcceptMethods(array $methods = array('GET', 'OPTIONS')) |
||
110 | |||
111 | /** |
||
112 | * Add new AcceptParsedBodyToken middleware. |
||
113 | * |
||
114 | * @see https://github.com/schnittstabil/get Documentation of `Schnittstabil\Get\getValue` |
||
115 | * |
||
116 | * @param string|int|mixed[] $path a `Schnittstabil\Get\getValue` path |
||
117 | * |
||
118 | * @return static |
||
119 | */ |
||
120 | public function withAcceptParsedBodyToken($path = 'X-XSRF-TOKEN') |
||
124 | |||
125 | /** |
||
126 | * Add new RespondWithCookieToken middleware. |
||
127 | * |
||
128 | * @param string $cookieName Cookie name |
||
129 | * @param callable $modify Allows to modify the cookie; same signature as `$this->modifyCookie` |
||
130 | * |
||
131 | * @return static |
||
132 | */ |
||
133 | public function withRespondWithCookieToken($cookieName = 'XSRF-TOKEN', callable $modify = null) |
||
137 | |||
138 | /** |
||
139 | * Add new RespondWithHeaderToken middleware. |
||
140 | * |
||
141 | * @param string $headerName Header field name |
||
142 | * |
||
143 | * @return static |
||
144 | */ |
||
145 | public function withRespondWithHeaderToken($headerName = 'XSRF-TOKEN') |
||
149 | } |
||
150 |