stable

Clone or download

Read-only

Remove DispatchableWithRequestNoAuthz::userCanAccess() API

The DispatchableWithRequestNoAuthz::userCanAccess() while trying to convoy the message that developers are completly by themselves when they use DispatchableWithRequestNoAuthz, it also comes with limitations: * it introduces a weakness in the dispatchable pattern: it comes with no guarantees that ::userCanAccess() will be called before ::process() so a state that would otherwise not be needed, needs to be kept by the implementors to ensure everything has been called in the expected order. This leads to either boilerplate code or no checks at all which break the promise initially made by the API. * it results in multiple entry and output points in the request handlers so customizing responses is harder. This is caused by the fact that DispatchableWithRequestNoAuthzAPI implementations tend to return more information than only a boolean when ::userCanAccess() is called. These use cases are legitimate you might not want to return a forbidden error when the resource can not be found for example. It will also be less easy to make this interface compliant with PSR-15 if we want to align Tuleap internals to PSR standards in the future. * with or without ::userCanAccess() developers still needs to think about access control has the default layer provided by \URLVerification is only high level. A lot of the existing implementations of DispatchableWithRequest in the codebase adds their own verifications without having a ::userCanAccess() method. This is part of request #12581: Git LFS error responses might be returned in a format that does not respect the specification Change-Id: I8d615dec352c8ee14b97da9aba2196c2a0141f7d

Modified Files

Name
M plugins/docman/include/Upload/FileUploadController.php +7 −2 Go to diff View file
M plugins/git/include/Git/HTTP/HTTPAccessControl.php +12 −6 Go to diff View file
M plugins/git/include/Git/HTTP/HTTPController.php +5 −19 Go to diff View file
M plugins/git/include/gitPlugin.class.php +1 −0 Go to diff View file
M plugins/git/phpunit/HTTP/HTTPAccessControlTest.php +21 −16 Go to diff View file
M plugins/gitlfs/include/Batch/LFSBatchController.php +31 −50 Go to diff View file
M plugins/gitlfs/include/HTTP/UserRetriever.php +2 −5 Go to diff View file
M plugins/gitlfs/include/LFSJSONHTTPDispatchable.php +1 −6 Go to diff View file
M plugins/gitlfs/include/Lock/Controller/LFSLockCreateController.php +42 −61 Go to diff View file
M plugins/gitlfs/include/Lock/Controller/LFSLockDeleteController.php +44 −60 Go to diff View file
M plugins/gitlfs/include/Lock/Controller/LFSLockListController.php +27 −46 Go to diff View file
M plugins/gitlfs/include/Lock/Controller/LFSLockVerifyController.php +35 −55 Go to diff View file
D plugins/gitlfs/include/Transfer/AuthorizedActionStore.php +0 −54 Go to diff View file
M plugins/gitlfs/include/Transfer/Basic/LFSBasicTransferDownloadController.php +6 −20 Go to diff View file
M plugins/gitlfs/include/Transfer/Basic/LFSBasicTransferUploadController.php +6 −19 Go to diff View file
M plugins/gitlfs/include/Transfer/LFSActionUserAccessHTTPRequestChecker.php +8 −9 Go to diff View file
M plugins/gitlfs/include/Transfer/LFSTransferVerifyController.php +6 −18 Go to diff View file
M plugins/gitlfs/include/gitlfsPlugin.class.php +6 −25 Go to diff View file
D plugins/gitlfs/phpunit/Transfer/AuthorizedActionStoreTest.php +0 −55 Go to diff View file
M plugins/gitlfs/phpunit/Transfer/LFSActionUserAccessHTTPRequestCheckerTest.php +18 −15 Go to diff View file
M plugins/mfa/include/Enrollment/EnrollmentDisplayController.php +5 −6 Go to diff View file
M plugins/mfa/include/Enrollment/EnrollmentRegisterController.php +5 −5 Go to diff View file
M plugins/prometheus_metrics/include/MetricsController.php +4 −9 Go to diff View file
M src/common/ForgeAccess/ForgeAccess.php +36 −9 Go to diff View file
M src/common/Request/DispatchableWithRequestNoAuthz.php +0 −8 Go to diff View file
M src/common/Request/FrontRouter.php +2 −6 Go to diff View file
M src/common/User/Profile/AvatarController.php +6 −17 Go to diff View file
M src/common/include/URLVerification.class.php +7 −12 Go to diff View file
A tests/phpunit/common/ForgeAccess/ForgeAccessTest.php +78 −0 Go to diff View file
M tests/phpunit/common/Request/FrontRouterTest.php +1 −26 Go to diff View file