The module I developed adds an additional layer of protection for user data in Nextcloud — the ability to set a separate password for a selected folder.
The password for the protected folder is not linked to the Nextcloud account password and is used as an additional layer of authentication.
The main idea is that standard authentication in Nextcloud is not sufficient to access the contents of a protected folder. When attempting to open such a folder, the user must additionally enter the password set for it.
Once protection is enabled, the module restricts access to the contents of the folder until additional authentication has been completed. This means that even if an unauthorized person gains access to an already authenticated Nextcloud account, they will not be able to simply open the protected folder through the web interface and view the files stored inside it.
At the same time, Nextcloud’s existing user system, access permissions, and authentication continue to work as usual. The module represents an additional layer of protection on top of Nextcloud’s existing access model, rather than replacing it.
How It Works
The user selects a folder that needs additional protection and sets a separate password for it.
After protection is activated:
- the folder is marked as protected;
- when attempting to open its contents, an additional password is requested;
- without successful password verification, access to the contents through the web interface is blocked;
- after successful authentication, the user gains access to the folder;
- the mechanism works independently of the user’s primary authentication in Nextcloud.
In practice, this makes it possible to create an additional private area within the regular user storage — a kind of “second layer”, access to which requires separate confirmation.
Current Implementation
At the moment, the module has been implemented and works properly in the web version of Nextcloud.
The project’s source code is stored in a private GitHub repository and has not yet been made publicly available.
Within the web interface, I was able to implement the core protection logic: identifying protected folders, requesting an additional password, and restricting access until additional authentication has been completed.
The Problem Encountered
The main problem appeared when using the official Nextcloud mobile applications for iPhone and Android.
The mobile clients use their own mechanisms for working with files and local caching. Because of this, some data may be retrieved or may already be stored on the device independently of the additional password verification implemented at the web interface level.
As a result, the protection works correctly in the browser but cannot guarantee the same level of access restriction through the mobile applications.
This is an architectural limitation of the current implementation.
Simply modifying the web interface is not sufficient, because full protection must also be enforced when accessing files through API, WebDAV, and mobile clients, and must properly interact with local caching mechanisms.
What Is Required for a Full Implementation
In my opinion, to turn this mechanism into a fully integrated Nextcloud feature, it needs to be integrated more deeply into the platform’s architecture.
Additional authentication verification should take place not only in the web interface, but also on the server side when protected data is accessed through different methods.
The behavior of the following must be defined separately:
- WebDAV;
- Nextcloud API;
- Android client;
- iOS client;
- file synchronization;
- local cache;
- previously downloaded files;
- shared folders and links;
- background synchronization;
- file downloads and uploads.
The issue of already cached data is particularly important: if a file was downloaded to a mobile device before a password was set on the folder, server-side protection alone cannot delete an already existing local copy. Therefore, a full implementation will require support for the protected folders mechanism directly within the mobile clients.
Project Goal
My goal is not simply to add a password prompt to the web interface, but to create a complete additional layer of folder protection that will be applied consistently regardless of the method used to access Nextcloud.
I am ready to provide the Nextcloud team with the source code of the existing module, a description of its architecture and current limitations, as well as participate in the further development of the solution and its integration at the platform level.