stable

Clone or download

Read-only

request #13492: Support overriding request's method with a header when serving Tus requests

The tus protocol specify [0] that the X-Http-Method-Override request header can be used by clients to override the actual request's method. This is useful for clients in an environnement where PATCH or DELETE methods are not supported (e.g. OpenJDK). This contribution however sets a few constraints: it's only possible to override request's method to and from POST, PATCH, PUT and DELETE methods. Methods like GET, OPTIONS and HEAD are voluntarily excluded because cross origin policies for those are more lax. They also do not benefit of the protection of the SameSite cookie attribute so they are more exposed to cross-site request forgery attacks. Methods like CONNECT, TRACE or LOCK are less common and it's very unlikely for a client to be able to use those but not POST or PATCH. To test you can use a tus client in a broken environnent (e.g. a Java one with OpenJDK) or directly simulate the protocol using curl: curl 'https://tuleap.example.com/uploads/myfile' \ -H 'X-Auth-AccessKey: tlp.k1.1026...' \ -H 'Tus-Resumable: 1.0.0' \ -H 'Upload-Offset: 0' \ -H 'Content-Type: application/offset+octet-stream' \ -H 'Content-Length: <filesize>' \ -H 'X-Http-Method-Override: PATCH' \ --data-binary "@/path/to/my/file" [0] https://tus.io/protocols/resumable-upload.html#x-http-method-override Change-Id: I85eda788709fd61fbe3388ec2f9d1399ffbde7f4

Modified Files

Name
M plugins/docman/include/docmanPlugin.class.php +2 −2 Go to diff View file
M plugins/frs/include/frsPlugin.class.php +1 −1 Go to diff View file
M plugins/tracker/include/trackerPlugin.class.php +1 −1 Go to diff View file
A src/common/Tus/TusRequestMethodOverride.php +66 −0 Go to diff View file
M src/common/Upload/FileUploadController.php +5 −2 Go to diff View file
M src/etc/nginx/tuleap.d/08-uploads.conf +4 −0 Go to diff View file
A tests/phpunit/common/Tus/TusRequestMethodOverrideTest.php +87 −0 Go to diff View file