Skip to content

Commit

Permalink
Fix bundling of web resources and update webui doc (#895)
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreyNikiforov authored Jul 6, 2024
1 parent c0924a7 commit 46b275a
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 11 deletions.
22 changes: 21 additions & 1 deletion docs/authentication.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://myaccount.google.com/apppasswords>

## 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.
Expand Down Expand Up @@ -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*
1 change: 1 addition & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ naming
mode
size
raw
webui
```
3 changes: 3 additions & 0 deletions docs/webui.md
Original file line number Diff line number Diff line change
@@ -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)
6 changes: 3 additions & 3 deletions scripts/build_bin_linux
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 3 additions & 3 deletions scripts/build_bin_macos
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 3 additions & 3 deletions scripts/build_bin_windows
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 7 additions & 0 deletions src/icloudpd/server/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import os
import sys
from logging import Logger
from typing import Union

Expand All @@ -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]:
Expand Down
2 changes: 1 addition & 1 deletion src/icloudpd/server/templates/status.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<div hx-get="/status" hx-trigger="every 1sec" hx-swap="outerHTML">
<div hx-get="/status" hx-trigger="every 10sec" hx-swap="outerHTML">
<p>Status: {{ status }}</p>
</div>

0 comments on commit 46b275a

Please sign in to comment.