1 | <?php |
||
33 | class CorsPlugin extends ServerPlugin { |
||
34 | |||
35 | /** |
||
36 | * Reference to main server object |
||
37 | * |
||
38 | * @var \Sabre\DAV\Server |
||
39 | */ |
||
40 | private $server; |
||
41 | |||
42 | /** |
||
43 | * Reference to logged in user's session |
||
44 | * |
||
45 | * @var IUserSession |
||
46 | */ |
||
47 | private $userSession; |
||
48 | |||
49 | /** |
||
50 | * @var string[] |
||
51 | */ |
||
52 | private $extraHeaders; |
||
53 | |||
54 | /** |
||
55 | * @param IUserSession $userSession |
||
56 | */ |
||
57 | public function __construct(IUserSession $userSession) { |
||
60 | |||
61 | private function getExtraHeaders(RequestInterface $request) { |
||
84 | |||
85 | /** |
||
86 | * This initializes the plugin. |
||
87 | * |
||
88 | * This function is called by \Sabre\DAV\Server, after |
||
89 | * addPlugin is called. |
||
90 | * |
||
91 | * This method should set up the required event subscriptions. |
||
92 | * |
||
93 | * @param \Sabre\DAV\Server $server |
||
94 | * @return void |
||
95 | */ |
||
96 | public function initialize(\Sabre\DAV\Server $server) { |
||
114 | |||
115 | /** |
||
116 | * This method sets the cors headers for all requests |
||
117 | * |
||
118 | * @param RequestInterface $request |
||
119 | * @param ResponseInterface $response |
||
120 | * @return void |
||
121 | */ |
||
122 | public function setCorsHeaders(RequestInterface $request, ResponseInterface $response) { |
||
132 | |||
133 | /** |
||
134 | * Handles the OPTIONS request |
||
135 | * |
||
136 | * @param RequestInterface $request |
||
137 | * @param ResponseInterface $response |
||
138 | * |
||
139 | * @return false |
||
140 | * @throws \InvalidArgumentException |
||
141 | */ |
||
142 | public function setOptionsRequestHeaders(RequestInterface $request, ResponseInterface $response) { |
||
157 | |||
158 | /** |
||
159 | * in addition to schemas used by extensions we ignore empty origin header |
||
160 | * values as well as 'null' which is not valid by the specification but used |
||
161 | * by some clients. |
||
162 | * @link https://github.com/owncloud/core/pull/32120#issuecomment-407008243 |
||
163 | * |
||
164 | * @param string $originHeader |
||
165 | * @return bool |
||
166 | */ |
||
167 | public function ignoreOriginHeader($originHeader) { |
||
174 | } |
||
175 |