diff --git a/docs/application-config-options.md b/docs/application-config-options.md index 1a266080f..b419fbb7d 100644 --- a/docs/application-config-options.md +++ b/docs/application-config-options.md @@ -816,9 +816,29 @@ _**Config Example:**_ ## Command Line Interface (CLI) Only Options ### CLI Option: --auth-files -_**Description:**_ +_**Description:**_ This CLI option allows the user to perform application authentication not via an interactive dialog but via specific files that the application uses to read the authentication data from. -_**Usage Example:**_ +_**Usage Example:**_ `onedrive --auth-files authUrl:responseUrl` + +_**Additional Usage Notes:**_ The authorisation URL is written to the specified 'authUrl' file, then onedrive waits for the file 'responseUrl' to be present, and reads the authentication response from that file. Example: + +```text +onedrive --auth-files '~/onedrive-auth-url:~/onedrive-response-url' +Reading configuration file: /home/alex/.config/onedrive/config +Configuration file successfully loaded +Configuring Global Azure AD Endpoints +Client requires authentication before proceeding. Waiting for --auth-files elements to be available. +``` +At this point, the client has written the file `~/onedrive-auth-url` which contains the authentication URL that needs to be visited to perform the authentication process. The client will now wait and watch for the presence of the file `~/onedrive-response-url`. + +Visit the authentication URL, and then create a new file called `~/onedrive-response-url` with the response URI. Once this has been done, the application will acknowledge the presence of this file, read the contents, and authenticate the application. +```text +Sync Engine Initialised with new Onedrive API instance + + --sync or --monitor switches missing from your command line input. Please add one (not both) of these switches to your command line or use 'onedrive --help' for further assistance. + +No OneDrive sync will be performed without one of these two arguments being present. +``` ### CLI Option: --auth-response _**Description:**_ diff --git a/src/config.d b/src/config.d index b8256c7c5..79cabe3e9 100644 --- a/src/config.d +++ b/src/config.d @@ -909,16 +909,25 @@ class ApplicationConfig { bool ignore_depreciation = false; - // min_notify_changes as been depreciated + // min_notify_changes has been depreciated if (key == "min_notify_changes") { - log.log("\nThis option 'min_notify_changes' has been depreciated and will be ignored. Please read the updated documentation and update your client configuration."); + log.log("\nThe option 'min_notify_changes' has been depreciated and will be ignored. Please read the updated documentation and update your client configuration."); + writeln(); + ignore_depreciation = true; + } + + // force_http_2 has been depreciated + if (key == "force_http_2") { + log.log("\nThe option 'force_http_2' has been depreciated and will be ignored. Please read the updated documentation and update your client configuration."); writeln(); ignore_depreciation = true; } // Application configuration update required for Business Shared Folders if (key == "sync_business_shared_folders") { - log.log("\nThe method to sync Business Shared Folders has changed. Please read the updated documentation and update your client configuration."); + log.log("\nThe process for synchronising Microsoft OneDrive Business Shared Folders has changed."); + log.log("Please review the revised documentation on how to configure this application feature. You must update your client configuration and make any necessary online adjustments accordingly."); + writeln(); } // Return false return ignore_depreciation; @@ -1151,6 +1160,54 @@ class ApplicationConfig { "Create a read-write shareable link for an existing file on OneDrive when used with --create-share-link ", &boolValues["with_editing_perms"] ); + + // Was --auth-files used? + if (!getValueString("auth_files").empty) { + // --auth-files used, need to validate that '~' was not used as a path identifier, and if yes, perform the correct expansion + string[] tempAuthFiles = getValueString("auth_files").split(":"); + string tempAuthUrl = tempAuthFiles[0]; + string tempResponseUrl = tempAuthFiles[1]; + string newAuthFilesString; + + // shell expansion if required + if (!shellEnvironmentSet){ + // No shell environment is set, no automatic expansion of '~' if present is possible + // Does the 'currently configured' tempAuthUrl include a ~ + if (canFind(tempAuthUrl, "~")) { + // A ~ was found in auth_files(authURL) + log.vdebug("auth_files: A '~' was found in 'auth_files(authURL)', using the calculated 'homePath' to replace '~' as no SHELL or USER environment variable set"); + tempAuthUrl = buildNormalizedPath(buildPath(defaultHomePath, strip(tempAuthUrl, "~"))); + } + + // Does the 'currently configured' tempAuthUrl include a ~ + if (canFind(tempResponseUrl, "~")) { + // A ~ was found in auth_files(authURL) + log.vdebug("auth_files: A '~' was found in 'auth_files(tempResponseUrl)', using the calculated 'homePath' to replace '~' as no SHELL or USER environment variable set"); + tempResponseUrl = buildNormalizedPath(buildPath(defaultHomePath, strip(tempResponseUrl, "~"))); + } + } else { + // Shell environment is set, automatic expansion of '~' if present is possible + // Does the 'currently configured' tempAuthUrl include a ~ + if (canFind(tempAuthUrl, "~")) { + // A ~ was found in auth_files(authURL) + log.vdebug("auth_files: A '~' was found in the configured 'auth_files(authURL)', automatically expanding as SHELL and USER environment variable is set"); + tempAuthUrl = expandTilde(tempAuthUrl); + } + + // Does the 'currently configured' tempAuthUrl include a ~ + if (canFind(tempResponseUrl, "~")) { + // A ~ was found in auth_files(authURL) + log.vdebug("auth_files: A '~' was found in the configured 'auth_files(tempResponseUrl)', automatically expanding as SHELL and USER environment variable is set"); + tempResponseUrl = expandTilde(tempResponseUrl); + } + } + + // Build new string + newAuthFilesString = tempAuthUrl ~ ":" ~ tempResponseUrl; + log.vdebug("auth_files - updated value: ", newAuthFilesString); + setValueString("auth_files", newAuthFilesString); + } + if (opt.helpWanted) { outputLongHelp(opt.options); exit(EXIT_SUCCESS); @@ -1188,7 +1245,6 @@ class ApplicationConfig { log.error("DEPRECIATION WARNING: --get-O365-drive-id has been depreciated in favour of --get-sharepoint-drive-id"); depreciatedCommandsFound = true; } - } if (depreciatedCommandsFound) { diff --git a/src/main.d b/src/main.d index 2d60a479c..aa9f8d91f 100644 --- a/src/main.d +++ b/src/main.d @@ -839,14 +839,6 @@ int main(string[] cliArgs) { return EXIT_FAILURE; } - /** - // Before we exit, if we are using --dry-run, clean up the local syste, - if (appConfig.getValueBool("dry_run")) { - // Cleanup any existing dry-run elements ... these should never be left hanging around - cleanupDryRunDatabaseFiles(appConfig.databaseFilePathDryRun); - } - **/ - // Exit application using exit scope if (!syncEngineInstance.syncFailures) { return EXIT_SUCCESS; diff --git a/src/sync.d b/src/sync.d index c9cb5ac88..b0b55ba7f 100644 --- a/src/sync.d +++ b/src/sync.d @@ -502,7 +502,6 @@ class SyncEngine { // - Process any items to add (download data to local) // - Detail any files that we failed to download // - Process any deletes (remove local data) - // - Walk local file system for any differences (new files / data to upload to OneDrive) void syncOneDriveAccountToLocalDisk() { // performFullScanTrueUp value @@ -6787,7 +6786,4 @@ class SyncEngine { log.error("Selected path not found on local system: ", inputFilePath); } } - - - } \ No newline at end of file