diff --git a/docs/authentication.md b/docs/authentication.md index 9e83f0617..9ada2a099 100644 --- a/docs/authentication.md +++ b/docs/authentication.md @@ -12,6 +12,20 @@ or you can send to a different email address with `--notification-email`. If you want to send notification emails using your Gmail account, and you have enabled two-factor authentication, you will need to generate an App Password at +## MFA Providers + +```{versionadded} 1.21.0 +``` + +There are two ways to provide MFA code to `icloudpd`: +- Using console +- Using web interface + +The choice can be made with `--mfa-provider` parameter. + +Default: *console* + + ## FIDO Authentication to iCloud with hardware keys (FIDO) is not supported. @@ -52,15 +66,21 @@ Use `icloud`, not `icloudpd` ```{versionadded} 1.20.0 ``` +```{versionadded} 1.21.0 +WebUI support +``` -Passwords for iCloud access can be supplied by user in three ways: +Passwords for iCloud access can be supplied by user in four ways: - Using `--password` command line parameter - Using keyring - Using console +- Using web interface It is possible to specify which of these three ways `icloudpd` should use, by specifying them with `--password-provider` parameter. More than one can be specified and the order of providers matches the order then will be checked for password. E.g. `--password-provider keyring --password-provider console` means that `icloudpd` will check password in keyring first and then, if no password found, ask for password in the console. Keyring password provider, if specified, saves valid password back into keyring. +Console and Web UI are not compatible with each other. Console or WebUI providers, if specified, must be last in the list of providers because they cannot be skipped. + Default set and order of providers are: *parameter*, *keyring*, *console* \ No newline at end of file diff --git a/docs/index.md b/docs/index.md index ffa8f522e..c49a0562b 100644 --- a/docs/index.md +++ b/docs/index.md @@ -15,4 +15,5 @@ naming mode size raw +webui ``` diff --git a/docs/webui.md b/docs/webui.md new file mode 100644 index 000000000..86c5bc216 --- /dev/null +++ b/docs/webui.md @@ -0,0 +1,3 @@ +# Web UI + +`icloudpd` can start internal web server on port 8080 and accept input (password and MFA code) from there instead of console. Web server is started only if `webui` selected for [MFA provider and/or Password Provider](authentication) \ No newline at end of file diff --git a/scripts/build_bin_linux b/scripts/build_bin_linux index 6a767a96f..76fb23a88 100755 --- a/scripts/build_bin_linux +++ b/scripts/build_bin_linux @@ -5,6 +5,6 @@ set -euo pipefail # expects python with installed dependencies # required params: version plat -pyinstaller --collect-all keyrings.alt --copy-metadata keyrings.alt --hidden-import pkg_resources.extern --hidden-import pkgutil --collect-all tzdata --onefile src/starters/icloudpd.py src/starters/icloud.py --name icloudpd-$1-linux-$2 -pyinstaller --collect-all keyrings.alt --copy-metadata keyrings.alt --hidden-import pkg_resources.extern --hidden-import pkgutil --collect-all tzdata --onefile src/starters/icloud.py --name icloud-$1-linux-$2 -pyinstaller --collect-all keyrings.alt --copy-metadata keyrings.alt --hidden-import pkg_resources.extern --hidden-import pkgutil --collect-all tzdata --onefile src/starters/icloudpd_ex.py --name icloudpd-ex-$1-linux-$2 +pyinstaller --collect-all keyrings.alt --copy-metadata keyrings.alt --hidden-import pkg_resources.extern --hidden-import pkgutil --collect-all tzdata --add-data "src/icloudpd/server/static:static" --add-data "src/icloudpd/server/templates:templates" --onefile src/starters/icloudpd.py src/starters/icloud.py --name icloudpd-$1-linux-$2 +pyinstaller --collect-all keyrings.alt --copy-metadata keyrings.alt --hidden-import pkg_resources.extern --hidden-import pkgutil --collect-all tzdata --add-data "src/icloudpd/server/static:static" --add-data "src/icloudpd/server/templates:templates" --onefile src/starters/icloud.py --name icloud-$1-linux-$2 +pyinstaller --collect-all keyrings.alt --copy-metadata keyrings.alt --hidden-import pkg_resources.extern --hidden-import pkgutil --collect-all tzdata --add-data "src/icloudpd/server/static:static" --add-data "src/icloudpd/server/templates:templates" --onefile src/starters/icloudpd_ex.py --name icloudpd-ex-$1-linux-$2 diff --git a/scripts/build_bin_macos b/scripts/build_bin_macos index 4c230cbc5..33cf8ef5e 100755 --- a/scripts/build_bin_macos +++ b/scripts/build_bin_macos @@ -5,6 +5,6 @@ set -euo pipefail # expects python with installed dependencies # required params: version arch -pyinstaller --collect-all keyrings.alt --copy-metadata keyrings.alt --hidden-import pkg_resources.extern --hidden-import pkgutil --collect-all tzdata --onefile src/starters/icloudpd.py src/starters/icloud.py --name icloudpd-$1-macos-$2 -pyinstaller --collect-all keyrings.alt --copy-metadata keyrings.alt --hidden-import pkg_resources.extern --hidden-import pkgutil --collect-all tzdata --onefile src/starters/icloud.py --name icloud-$1-macos-$2 -pyinstaller --collect-all keyrings.alt --copy-metadata keyrings.alt --hidden-import pkg_resources.extern --hidden-import pkgutil --collect-all tzdata --onefile src/starters/icloudpd_ex.py --name icloudpd-ex-$1-macos-$2 +pyinstaller --collect-all keyrings.alt --copy-metadata keyrings.alt --hidden-import pkg_resources.extern --hidden-import pkgutil --collect-all tzdata --add-data "src/icloudpd/server/static:static" --add-data "src/icloudpd/server/templates:templates" --onefile src/starters/icloudpd.py src/starters/icloud.py --name icloudpd-$1-macos-$2 +pyinstaller --collect-all keyrings.alt --copy-metadata keyrings.alt --hidden-import pkg_resources.extern --hidden-import pkgutil --collect-all tzdata --add-data "src/icloudpd/server/static:static" --add-data "src/icloudpd/server/templates:templates" --onefile src/starters/icloud.py --name icloud-$1-macos-$2 +pyinstaller --collect-all keyrings.alt --copy-metadata keyrings.alt --hidden-import pkg_resources.extern --hidden-import pkgutil --collect-all tzdata --add-data "src/icloudpd/server/static:static" --add-data "src/icloudpd/server/templates:templates" --onefile src/starters/icloudpd_ex.py --name icloudpd-ex-$1-macos-$2 diff --git a/scripts/build_bin_windows b/scripts/build_bin_windows index ebb3f7d75..63f3aecec 100755 --- a/scripts/build_bin_windows +++ b/scripts/build_bin_windows @@ -5,6 +5,6 @@ set -euo pipefail # expects python with installed dependencies # required param: version arch -pyinstaller --collect-all keyrings.alt --copy-metadata keyrings.alt --hidden-import pkg_resources.extern --hidden-import pkgutil --collect-all tzdata --onefile src/starters/icloudpd.py src/starters/icloud.py --name icloudpd-$1-windows-$2 -pyinstaller --collect-all keyrings.alt --copy-metadata keyrings.alt --hidden-import pkg_resources.extern --hidden-import pkgutil --collect-all tzdata --onefile src/starters/icloud.py --name icloud-$1-windows-$2 -pyinstaller --collect-all keyrings.alt --copy-metadata keyrings.alt --hidden-import pkg_resources.extern --hidden-import pkgutil --collect-all tzdata --onefile src/starters/icloudpd_ex.py --name icloudpd-ex-$1-windows-$2 +pyinstaller --collect-all keyrings.alt --copy-metadata keyrings.alt --hidden-import pkg_resources.extern --hidden-import pkgutil --collect-all tzdata --add-data "src/icloudpd/server/static;static" --add-data "src/icloudpd/server/templates;templates" --onefile src/starters/icloudpd.py src/starters/icloud.py --name icloudpd-$1-windows-$2 +pyinstaller --collect-all keyrings.alt --copy-metadata keyrings.alt --hidden-import pkg_resources.extern --hidden-import pkgutil --collect-all tzdata --add-data "src/icloudpd/server/static;static" --add-data "src/icloudpd/server/templates;templates" --onefile src/starters/icloud.py --name icloud-$1-windows-$2 +pyinstaller --collect-all keyrings.alt --copy-metadata keyrings.alt --hidden-import pkg_resources.extern --hidden-import pkgutil --collect-all tzdata --add-data "src/icloudpd/server/static;static" --add-data "src/icloudpd/server/templates;templates" --onefile src/starters/icloudpd_ex.py --name icloudpd-ex-$1-windows-$2 diff --git a/src/icloudpd/server/__init__.py b/src/icloudpd/server/__init__.py index 2b8e90d1d..9218a6a72 100644 --- a/src/icloudpd/server/__init__.py +++ b/src/icloudpd/server/__init__.py @@ -1,3 +1,5 @@ +import os +import sys from logging import Logger from typing import Union @@ -10,6 +12,11 @@ def serve_app(logger: Logger, _status_exchange: StatusExchange) -> None: app = Flask(__name__) app.logger = logger + # for running in pyinstaller + bundle_dir = getattr(sys, "_MEIPASS", None) + if bundle_dir is not None: + app.template_folder = os.path.join(bundle_dir, "templates") + app.static_folder = os.path.join(bundle_dir, "static") @app.route("/") def index() -> Union[Response, str]: diff --git a/src/icloudpd/server/templates/status.html b/src/icloudpd/server/templates/status.html index a5a0059b1..411af315b 100644 --- a/src/icloudpd/server/templates/status.html +++ b/src/icloudpd/server/templates/status.html @@ -1,3 +1,3 @@ -
+

Status: {{ status }}

\ No newline at end of file