diff --git a/README.md b/README.md index 1fe234ec..625ca8d5 100644 --- a/README.md +++ b/README.md @@ -417,32 +417,117 @@ For more discussion on managed and paid hosting options see here: +docker compose up -d # start the Web UI server in the background +docker compose run archivebox add 'https://example.com' # add a test URL to snapshot w/ Docker Compose + +archivebox list 'https://example.com' # fetch it with pip-installed archivebox on the host +docker compose run archivebox list 'https://example.com' # or w/ Docker Compose +docker run -it -v $PWD:/data archivebox/archivebox list 'https://example.com' # or w/ Docker, all equivalent + + + +
+ +##### Bare Metal Usage (`pip`/`apt`/`brew`/etc.) + +
+
+Click to expand... +
+ +

+archivebox init --setup      # safe to run init multiple times (also how you update versions)
+archivebox version           # get archivebox version info and more
+archivebox add --depth=1 'https://news.ycombinator.com'
+
+ +
+
+ +##### Docker Compose Usage + +
+
+Click to expand... +
+ +

+# make sure you have `docker-compose.yml` from the Quickstart instructions first
+docker compose run archivebox init --setup
+docker compose run archivebox version
+docker compose run archivebox add --depth=1 'https://news.ycombinator.com'
+
+ +
+
+ +##### Docker Usage + +
+
+Click to expand... +
+ +

+docker run -v $PWD:/data -it archivebox/archivebox init --setup
+docker run -v $PWD:/data -it archivebox/archivebox version
+
+ +
+
+ +#### Next Steps + +- `archivebox help/version` to see the list of available subcommands and currently installed version info - `archivebox setup/init/config/status/manage` to administer your collection - `archivebox add/schedule/remove/update/list/shell/oneshot` to manage Snapshots in the archive - `archivebox schedule` to pull in fresh URLs regularly from [bookmarks/history/Pocket/Pinboard/RSS/etc.](#input-formats) + #### 🖥  Web UI Usage +##### Start the Web Server ```bash -archivebox manage createsuperuser # create admin user via CLI (or use ADMIN_PASSWORD env variable) +# Bare metal (pip/apt/brew/etc): archivebox server 0.0.0.0:8000 # open http://127.0.0.1:8000 to view it -# you can also configure whether or not login is required for most features -archivebox config --set PUBLIC_INDEX=False -archivebox config --set PUBLIC_SNAPSHOTS=False -archivebox config --set PUBLIC_ADD_VIEW=False +# Docker Compose: +docker compose up + +# Docker: +docker run -v $PWD:/data -it -p 8000:8000 archivebox/archivebox ``` +##### Allow Public Access or Create an Admin User +```bash +archivebox manage createsuperuser # create a new admin username & pass +# OR # OR +archivebox config --set PUBLIC_ADD_VIEW=True # allow guests to submit URLs +archivebox config --set PUBLIC_SNAPSHOTS=True # allow guests to see snapshot content +archivebox config --set PUBLIC_INDEX=True # allow guests to see list of all snapshots + +# restart the server to apply any config changes +``` + +*Docker hint:* Set the [`ADMIN_USERNAME` & `ADMIN_PASSWORD`)](https://github.com/ArchiveBox/ArchiveBox/wiki/Configuration#admin_username--admin_password) env variables to auto-create an admin user on first-run. + #### 🗄  SQL/Python/Filesystem Usage ```bash diff --git a/archivebox/config.py b/archivebox/config.py index b7c0f394..be75ffdc 100644 --- a/archivebox/config.py +++ b/archivebox/config.py @@ -112,6 +112,7 @@ CONFIG_SCHEMA: Dict[str, ConfigDefaultDict] = { 'LDAP_FIRSTNAME_ATTR': {'type': str, 'default': None}, 'LDAP_LASTNAME_ATTR': {'type': str, 'default': None}, 'LDAP_EMAIL_ATTR': {'type': str, 'default': None}, + 'LDAP_CREATE_SUPERUSER': {'type': bool, 'default': False}, }, 'ARCHIVE_METHOD_TOGGLES': { diff --git a/archivebox/core/apps.py b/archivebox/core/apps.py index ab840ff5..71c004d4 100644 --- a/archivebox/core/apps.py +++ b/archivebox/core/apps.py @@ -8,3 +8,8 @@ class CoreAppConfig(AppConfig): # WIP: broken by Django 3.1.2 -> 4.0 migration default_auto_field = 'django.db.models.UUIDField' + + def ready(self): + from .auth import register_signals + + register_signals() diff --git a/archivebox/core/auth.py b/archivebox/core/auth.py new file mode 100644 index 00000000..fb15d5a8 --- /dev/null +++ b/archivebox/core/auth.py @@ -0,0 +1,13 @@ +import os +from django.conf import settings +from ..config import ( + LDAP +) + +def register_signals(): + + if LDAP: + import django_auth_ldap.backend + from .auth_ldap import create_user + + django_auth_ldap.backend.populate_user.connect(create_user) diff --git a/archivebox/core/auth_ldap.py b/archivebox/core/auth_ldap.py new file mode 100644 index 00000000..9057683c --- /dev/null +++ b/archivebox/core/auth_ldap.py @@ -0,0 +1,12 @@ +from django.conf import settings +from ..config import ( + LDAP_CREATE_SUPERUSER +) + +def create_user(sender, user=None, ldap_user=None, **kwargs): + + if not user.id and LDAP_CREATE_SUPERUSER: + user.is_superuser = True + + user.is_staff = True + print(f'[!] WARNING: Creating new user {user} based on LDAP user {ldap_user} (is_staff={user.is_staff}, is_superuser={user.is_superuser})')