Compare commits

...

7 Commits

Author SHA1 Message Date
Artemis 406246d0b9
Merge 26b6c6e883 into 3c2356b9b4 2024-04-30 17:35:37 +01:00
Victor Lin 3c2356b9b4
Update macOS install (#545)
* Remove install for shards

shards is not available as a Homebrew package. Instead, it comes with
the crystal package.

<https://crystal-lang.org/reference/1.12/man/shards/index.html#installation>

* Fix postgresql package name

* Add createdb

Fixes initial error:

    FATAL:  database "<user>" does not exist

<https://stackoverflow.com/a/17936043>

* Clone repo before PostgreSQL setup

The PostgreSQL setup uses config files from the repo.

* Fix PostgreSQL name in headings

* Give PostgreSQL role login permissions

Fixes an error upon running the first script:

   FATAL:  role "kemal" is not permitted to log in

* Remove nonexistent script

* Use make for Invidious setup

Copied from Linux section
2024-04-29 11:20:07 +02:00
artemislena 26b6c6e883
T.: Add newline 2024-04-19 20:26:51 +02:00
artemislena ac8e0b9fef
T.: Don't change this file 2024-04-19 20:26:37 +02:00
artemislena 4adc95224b
T.: Improved string escapes in our scripts 2023-12-16 17:42:15 +01:00
artemislena 676a6800f7
T.: Document manual user registration 2023-10-24 19:33:28 +02:00
artemislena d9a641f6d7
T.: Document ways for resetting passwords just w standard shell utils 2023-10-24 19:33:08 +02:00
3 changed files with 63 additions and 12 deletions

View File

@ -138,7 +138,7 @@ git clone https://github.com/iv-org/invidious
exit
```
#### Set up PostgresSQL
#### Set up PostgreSQL
```bash
systemctl enable --now postgresql
@ -177,14 +177,22 @@ systemctl enable --now invidious.service
```bash
brew update
brew install shards crystal postgres imagemagick librsvg
brew install crystal postgresql imagemagick librsvg
```
#### Set up PostgresSQL
#### Clone the Invidious repository
```bash
git clone https://github.com/iv-org/invidious
cd invidious
```
#### Set up PostgreSQL
```bash
brew services start postgresql
psql -c "CREATE ROLE kemal WITH PASSWORD 'kemal';" # Change 'kemal' here to a stronger password, and update `password` in config/config.yml
createdb
psql -c "CREATE ROLE kemal WITH LOGIN PASSWORD 'kemal';" # Change 'kemal' here to a stronger password, and update `password` in config/config.yml
createdb -O kemal invidious
psql invidious kemal < config/sql/channels.sql
psql invidious kemal < config/sql/videos.sql
@ -193,7 +201,6 @@ psql invidious kemal < config/sql/users.sql
psql invidious kemal < config/sql/session_ids.sql
psql invidious kemal < config/sql/nonces.sql
psql invidious kemal < config/sql/annotations.sql
psql invidious kemal < config/sql/privacy.sql
psql invidious kemal < config/sql/playlists.sql
psql invidious kemal < config/sql/playlist_videos.sql
```
@ -201,12 +208,10 @@ psql invidious kemal < config/sql/playlist_videos.sql
#### Set up Invidious
```bash
git clone https://github.com/iv-org/invidious
cd invidious
shards install --production
crystal build src/invidious.cr --release
make
# Configure config/config.yml as you like
cp config/config.example.yml config/config.yml
# Configure config/config.yml how you want
```
### Windows

29
docs/register-user.md Normal file
View File

@ -0,0 +1,29 @@
# Registering users manually
You might want to disable registration in your [instance config](/configuration), but still have a quick way to manually register users upon request. To do so, first set up a separate instance that only listens on localhost, has registration enabled,
and captchas as well as background jobs disabled. Make sure you have a way to start it easily with just one or a few commands, e.g. via a systemd service. Then, use something like the script below (in the example, the instance is started via a systemd
service called `podman-invidious_register`, and it listens on localhost port 21742. **Warning**: This script is vulnerable to SQL injections. Only use trusted inputs; if you want to make a custom signup form and use this as a backend, be sure to
sanitize inputs.
```sh
#!/usr/bin/env bash
set -e
systemctl start podman-invidious_register
CONTINUE='y'
while [ "$CONTINUE" = 'y' ]; do
read -rp 'User ID: ' ID
if [ "$(su postgres -c "psql invidious -c \"SELECT email FROM users WHERE email = '\"'$ID'\"';\"" | tail -n 2 | head -n 1)" != '(0 rows)' ]; then
echo 'Error: User ID is already taken'
continue
fi
read -rsp 'Password: ' PASSWORD
curl -L 'http://localhost:21742/login' --form-string "email=$ID" --form-string "password=$PASSWORD" -F 'action=signin' >/dev/null
read -rp 'Register more accounts? [y/N] ' CONTINUE
done
systemctl stop podman-invidious_register
```

View File

@ -4,10 +4,11 @@ Resetting a user's invidious password needs you to edit the database.
Firstly, generate a bcrypt-encrypted hash for the new password you want to set for the user.
This can be done with the `bcrypt` python module, though there are other ways of doing the same.
This can, for example, be done with the `bcrypt` python module or the `mkpasswd` shell utility (the latter should be preinstalled on most systems):
```
python3 -c 'import bcrypt; print(bcrypt.hashpw(b"<INSERT PASSWORD HERE>", bcrypt.gensalt(rounds=10)).decode("ascii"))'
python3 -c 'import bcrypt; print(bcrypt.hashpw(b"<INSERT PASSWORD HERE>", bcrypt.gensalt(rounds=10)).decode("ascii"))' # python
mkpasswd --method=bcrypt-a -R 10 # mkpasswd
```
To do so, first attach to the database:
@ -23,3 +24,19 @@ UPDATE users SET password = 'HASH' WHERE email = 'USERNAME';
```
After that, the password should be reset.
This script bundles all needed commands so you don't have to enter everything manually every time, and also checks that the username exists before writing to the database:
```sh
#!/bin/sh
set -e
printf 'User ID: '
read -r ID
if [ "$(su postgres -c "psql invidious -c \"SELECT email FROM users WHERE email = '$ID';\"" | tail -n 2 | head -n 1)" != '(1 row)' ]; then
echo 'Error: User ID does not exist'
exit 1
fi
HASH="$(mkpasswd --method=bcrypt-a -R 10)"
su postgres -c "psql invidious -c \"UPDATE users SET password = '\"'$HASH'\"' WHERE email = '\"'$ID'\"';\""
```