user_backend_sql_raw
user_backend_sql_raw copied to clipboard
Custom queries for files_external variable replacement
Proposed enhancement:
Nextcloud's own app (files_external) for external storage (webdav,sftp,smb etc.) provides a mechanism for specifying servers, mount paths, user names and credentials using variables. On it's own, it only replaces the variable $user, but other apps can register handlers to replace additional variables. This is what Nextcloud's LDAP app does (see doc for specifying paths for external mount points, the file for the LDAP variable handler and the place, where it is registered).
Obviously, user_backend_sql_raw would be an excellent candidate for an app that uses this interface, i.e., users would specify an array custom_replacements with entries like smbuser=> 'SELECT ...', smbmnt => 'SELECT ...' and davmnt => 'SELECT something_else ...' and use $smbmnt and $smbuser and $davmnt as variables for files_external.
As opposed to other feature requests for additional functionality, such functionality does not hack into Nextcloud's internals in an unpredictable way that might not be future-proof. Except for one detail, the handler mechanism in files_external is quite well designed.
Currently, I have some working draft code that uses a third app that hooks into user_backend_sql_raw to achieve this, but I assume this would be useful for others, too. Thus, I'd like to prepare a pull request, if you're interested. It would take some time (likely not before end of August) until the pull request, as I've stuffed code in a single file/class that must be separated, but I want to check interest first.
Remark: I work for the Federal Office for Radiation Protection in Germany, so the forked repo would become part of OpenBfS.