Skip to content

Commit

Permalink
docs: update development docs (#329)
Browse files Browse the repository at this point in the history
  • Loading branch information
J0 authored Apr 3, 2024
1 parent aec9139 commit 1b0b2b2
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 10 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.1.47
1.1.48
60 changes: 51 additions & 9 deletions docs/development/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,59 @@ Launch the Supavisor application:
make dev
```

Start the Supavisor database to store tenant information:

```
make db_start && make db_migrate
```

You need to add tenants to the database. For example, the following request will add the `dev_tenant` with credentials to the database set up earlier.

## Add/update tenant

```bash
curl -X PUT \
'http://localhost:4000/api/tenants/dev_tenant \
--header 'Accept: */*' \
--header 'User-Agent: Thunder Client (https://www.thunderclient.com)' \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJvbGUiOiJhbm9uIiwiaWF0IjoxNjQ1MTkyODI0LCJleHAiOjE5NjA3Njg4MjR9.M9jrxyvPLkUxWgOYSf5dNdJ8v_eRrq810ShFRT8N-6M' \
--header 'Content-Type: application/json' \
--data-raw '{
"tenant": {
"db_host": "localhost",
"db_port": 6432,
"db_database": "postgres",
"ip_version": "auto",
"enforce_ssl": false,
"require_user": false,
"auth_query": "SELECT rolname, rolpassword FROM pg_authid WHERE rolname=$1;",
"users": [
{
"db_user": "postgres",
"db_password": "postgres",
"pool_size": 20,
"mode_type": "transaction",
"is_manager": true
}
]
}
}'
```
Now, it's possible to connect through the proxy. By default, Supavisor uses port `6543` for transaction mode and `5432` for session mode:

```
psql postgresql://postgres.dev_tenant:postgres@localhost:6543/postgres
```
> :warning: The tenant's ID is incorporated into the username and separated by the `.` symbol. For instance, for the username `some_username` belonging to the tenant `some_tenant`, the modified username will be `some_username.some_tenant`. This approach enables the system to support multi-tenancy on a single IP address.
As a general note, if you are not using the `Makefile` you will have to set a `VAULT_ENC_KEY` which should be at least 32 bytes long.
## General Commands
Here's an overview of the commands and the options you can use.
### Add/update tenant
```bash
curl -X PUT \
Expand Down Expand Up @@ -40,14 +90,6 @@ curl -X PUT \
}'
```

Now, it's possible to connect through the proxy. By default, Supavisor uses port `6543` for transaction mode and `5432` for session mode:

```
psql postgresql://postgres.dev_tenant:postgres@localhost:6543/postgres
```

> :warning: The tenant's ID is incorporated into the username and separated by the `.` symbol. For instance, for the username `some_username` belonging to the tenant `some_tenant`, the modified username will be `some_username.some_tenant`. This approach enables the system to support multi-tenancy on a single IP address.
## Delete tenant

To delete a tenant, send the following request:
Expand Down

0 comments on commit 1b0b2b2

Please sign in to comment.