use OCA\FederatedFileSharing\FederatedShareProvider;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http;
+use OCP\AppFramework\Http\Attribute\BruteForceProtection;
+use OCP\AppFramework\Http\Attribute\NoAdminRequired;
+use OCP\AppFramework\Http\Attribute\NoCSRFRequired;
use OCP\AppFramework\Http\Attribute\OpenAPI;
+use OCP\AppFramework\Http\Attribute\PublicPage;
use OCP\AppFramework\Http\JSONResponse;
use OCP\Constants;
use OCP\Federation\ICloudIdManager;
/**
* send federated share to a user of a public link
*
- * @NoCSRFRequired
- * @PublicPage
- * @BruteForceProtection(action=publicLink2FederatedShare)
- *
* @param string $shareWith Username to share with
* @param string $token Token of the share
* @param string $password Password of the share
* 200: Remote URL returned
* 400: Creating share is not possible
*/
+ #[NoCSRFRequired]
+ #[PublicPage]
+ #[BruteForceProtection(action: 'publicLink2FederatedShare')]
public function createFederatedShare($shareWith, $token, $password = '') {
if (!$this->federatedShareProvider->isOutgoingServer2serverShareEnabled()) {
return new JSONResponse(
/**
* ask other server to get a federated share
*
- * @NoAdminRequired
- *
* @param string $token
* @param string $remote
* @param string $password
* @param string $name (only for legacy reasons, can be removed with legacyMountPublicLink())
* @return JSONResponse
*/
+ #[NoAdminRequired]
public function askForFederatedShare($token, $remote, $password = '', $owner = '', $ownerDisplayName = '', $name = '') {
// check if server admin allows to mount public links from other servers
if ($this->federatedShareProvider->isIncomingServer2serverShareEnabled() === false) {
use OCA\FederatedFileSharing\Notifications;
use OCP\App\IAppManager;
use OCP\AppFramework\Http;
+use OCP\AppFramework\Http\Attribute\NoCSRFRequired;
use OCP\AppFramework\Http\Attribute\OpenAPI;
+use OCP\AppFramework\Http\Attribute\PublicPage;
use OCP\AppFramework\OCS\OCSBadRequestException;
use OCP\AppFramework\OCS\OCSException;
use OCP\AppFramework\OCSController;
}
/**
- * @NoCSRFRequired
- * @PublicPage
- *
* create a new share
*
* @param string|null $remote Address of the remote
*
* 200: Share created successfully
*/
+ #[NoCSRFRequired]
+ #[PublicPage]
public function createShare(
?string $remote = null,
?string $token = null,
}
/**
- * @NoCSRFRequired
- * @PublicPage
- *
* create re-share on behalf of another user
*
* @param int $id ID of the share
*
* 200: Remote share returned
*/
+ #[NoCSRFRequired]
+ #[PublicPage]
public function reShare(int $id, ?string $token = null, ?string $shareWith = null, ?int $remoteId = 0) {
if ($token === null ||
$shareWith === null ||
/**
- * @NoCSRFRequired
- * @PublicPage
- *
* accept server-to-server share
*
* @param int $id ID of the remote share
*
* 200: Share accepted successfully
*/
+ #[NoCSRFRequired]
+ #[PublicPage]
public function acceptShare(int $id, ?string $token = null) {
$notification = [
'sharedSecret' => $token,
}
/**
- * @NoCSRFRequired
- * @PublicPage
- *
* decline server-to-server share
*
* @param int $id ID of the remote share
*
* 200: Share declined successfully
*/
+ #[NoCSRFRequired]
+ #[PublicPage]
public function declineShare(int $id, ?string $token = null) {
$notification = [
'sharedSecret' => $token,
}
/**
- * @NoCSRFRequired
- * @PublicPage
- *
* remove server-to-server share if it was unshared by the owner
*
* @param int $id ID of the share
*
* 200: Share unshared successfully
*/
+ #[NoCSRFRequired]
+ #[PublicPage]
public function unshare(int $id, ?string $token = null) {
if (!$this->isS2SEnabled()) {
throw new OCSException('Server does not support federated cloud sharing', 503);
/**
- * @NoCSRFRequired
- * @PublicPage
- *
* federated share was revoked, either by the owner or the re-sharer
*
* @param int $id ID of the share
*
* 200: Share revoked successfully
*/
+ #[NoCSRFRequired]
+ #[PublicPage]
public function revoke(int $id, ?string $token = null) {
try {
$provider = $this->cloudFederationProviderManager->getCloudFederationProvider('file');
}
/**
- * @NoCSRFRequired
- * @PublicPage
- *
* update share information to keep federated re-shares in sync
*
* @param int $id ID of the share
*
* 200: Permissions updated successfully
*/
+ #[NoCSRFRequired]
+ #[PublicPage]
public function updatePermissions(int $id, ?string $token = null, ?int $permissions = null) {
$ncPermissions = $permissions;
}
/**
- * @NoCSRFRequired
- * @PublicPage
- *
* change the owner of a server-to-server share
*
* @param int $id ID of the share
*
* 200: Share moved successfully
*/
+ #[NoCSRFRequired]
+ #[PublicPage]
public function move(int $id, ?string $token = null, ?string $remote = null, ?string $remote_id = null) {
if (!$this->isS2SEnabled()) {
throw new OCSException('Server does not support federated cloud sharing', 503);