Repository navigation
Quick Start
This tutorial gets KeyAnyWhere running on your own computer in about ten minutes, using the web server built into CakePHP. It is the right path to evaluate the application or to start developing. At the end you will have created the administrator account, turned on its second authentication factor and logged in.
Warning
This setup is for a local computer only: it runs in development mode, over plain HTTP, with the secrets in a file inside the project. To install KeyAnyWhere for real use, follow the production installation.
You need a Debian 13 (or similar) computer where you can run sudo, and an authenticator app on your phone (any TOTP app, such as Aegis, Google Authenticator or 1Password). The Requirements page lists the versions.
This step installs PHP with the extensions KeyAnyWhere uses, Composer, Git and PostgreSQL.
sudo apt updatesudo apt install -y git unzip composer postgresql php8.4-cli php8.4-intl php8.4-mbstring php8.4-pgsql php8.4-xml php8.4-zipCheck that PHP is version 8.4 or later:
php -vThis step clones the repository into a keyanywhere folder and installs the PHP dependencies, including the development tools (tests, code analysis).
git clone https://github.com/arthusantiago/KeyAnyWhere.git keyanywherecd keyanywherecomposer installWhen Composer asks Set Folder Permissions ? (Default to Y), press Enter.
KeyAnyWhere needs one database for the application and, if you will run the tests, a second one for them. This step creates a PostgreSQL user with a random password and both databases.
Generate the password and keep it in a shell variable for the next steps:
KAW_DB_PASSWORD=$(php -r 'echo bin2hex(random_bytes(16));')sudo -u postgres psql -c "CREATE ROLE kaw LOGIN PASSWORD '$KAW_DB_PASSWORD';"sudo -u postgres createdb --owner=kaw keyanywheresudo -u postgres createdb --owner=kaw keyanywhere_testIn development, KeyAnyWhere reads its settings from config/.env (environment variables) and config/app_local.php (settings that override config/app.php). Both come from versioned examples and are ignored by Git. composer install already created config/app_local.php in step 2. This step creates config/.env and fills in the database access and the three secrets with freshly generated values.
cp config/.env.example config/.envsed -i \
-e "s|^export SECURITY_SALT=.*|export SECURITY_SALT=\"$(php -r 'echo bin2hex(random_bytes(32));')\"|" \
-e "s|^export KEY_CRIPTOGRAFIC=.*|export KEY_CRIPTOGRAFIC=\"$(php -r 'echo sodium_bin2hex(sodium_crypto_secretbox_keygen());')\"|" \
-e "s|^export CONFIG_INICIAL_TOKEN=.*|export CONFIG_INICIAL_TOKEN=\"$(php -r 'echo bin2hex(random_bytes(32));')\"|" \
-e "s|^export DB_DEFAULT_USER=.*|export DB_DEFAULT_USER=\"kaw\"|" \
-e "s|^export DB_DEFAULT_PASSWORD=.*|export DB_DEFAULT_PASSWORD=\"$KAW_DB_PASSWORD\"|" \
-e "s|^export DB_DEFAULT_NAME=.*|export DB_DEFAULT_NAME=\"keyanywhere\"|" \
-e "s|^export DB_TEST_USER=.*|export DB_TEST_USER=\"kaw\"|" \
-e "s|^export DB_TEST_PASSWORD=.*|export DB_TEST_PASSWORD=\"$KAW_DB_PASSWORD\"|" \
-e "s|^export DB_TEST_NAME=.*|export DB_TEST_NAME=\"keyanywhere_test\"|" \
config/.envThe Generating Security Keys page explains what each secret protects. Each variable in the file is described in Environment Variables.
The migrations create every table KeyAnyWhere uses. This step runs them and, optionally, loads example data.
bin/cake migrations migrateTo get ten example categories with twenty entries each (useful to see the screens with content), run:
bin/cake seeds run CategoriasSeed,EntradasSeedThe insecure password catalog is optional on a local computer. Without it, the warning about common passwords simply never appears.
CakePHP has a small web server for development. This step starts it on port 8765; leave this terminal open while you use KeyAnyWhere.
bin/cake serverA fresh installation has no users. The first-run setup creates the first one, who is the administrator (root), and only opens with the CONFIG_INICIAL_TOKEN generated in step 4. In a second terminal, inside the keyanywhere folder, print the setup address:
echo "http://localhost:8765/users/config-inicial?token=$(grep '^export CONFIG_INICIAL_TOKEN=' config/.env | cut -d'"' -f2)"Open the printed address in your browser and:
- Fill in the name, e-mail and password of the administrator and save.
- On the next screen, scan the QR code with your authenticator app (or, if you can't scan it, type in the app the key shown below it). Only then click Completar configuração (Complete setup): the QR code and the key are not shown again.
First-Run Setup explains this flow and its error messages.
Open http://localhost:8765/ and log in: your e-mail in Usuário (User), your password in Senha (Password) and the current 6-digit code from your authenticator app in Segundo fator de autenticação (Second authentication factor). You should see the home page, Minha Segurança (My Security).
- Learn the screens: User Guide.
- Run the tests and the code checks: Development Environment.
- Install it for real use: Production Overview.
Source code · Issues · Releases · Packagist · Online demo · Hosted edition
1. Getting started
2. Installing in production
- Overview
- Preparing the Server
- Installing KeyAnyWhere
- File Permissions
- Generating Security Keys
- Environment Variables
- Configuration Files
- Database Setup
- Insecure Password Catalog
- Web Server and HTTPS
- First-Run Setup
3. Operating your installation
4. Using KeyAnyWhere
5. Security
6. Development
7. Extending