README, bbconf updates

This commit is contained in:
Markus Thielen 2023-03-24 13:35:35 +01:00
parent 9a53cfbaa6
commit a2bd70edaf
5 changed files with 204 additions and 53 deletions

View File

@ -9,24 +9,60 @@ The `bbconf` folder contains basebox config files, database schema, type maps et
[VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur)
## Customize configuration
## Installation
See [Vite Configuration Reference](https://vitejs.dev/config/).
To install this app, you need
## Project Setup
* npm, node.js
* A PostgreSQL server, preferably on the local host (simpler)
* basebox components (broker, dbproxy, bbc)
* Keycloak
```sh
npm install
### PostgreSQL Preparation
You need to create a user and a database for the todo app. The recommended way to run basebox is to have a dedicated Unix user for dbproxy that authenticates to PostgreSQL using Peer authentication. This way, no password for the DB user has to be stored anywhere. The Unix user's name must match the name of the PostgreSQL user. For more info, see the basebox installation instructions and [PostgreSQL documentation](https://www.postgresql.org/docs/current/auth-peer.html).
For simplicity's sake, we are using a normal PostgreSQL user that authenticates using md5 authentication, thus requires a password, which is set in the dbproxy configuration file.
´´´sh
# Under (Debian) Linux, switch to the postgres user first:
# sudo su postgres
createuser -DRP bb_todo # default password: basebox
createdb -O bb_todo bb_todo
```
### Compile and Hot-Reload for Development
Tell PostgreSQL that the `bb_todo` user connects to the database using md5 authentication. To do so, edit `/etc/postgresql/<PostgreSQL version>/main/pg_hba.conf` (on Debian based Linux systems) to contain the following:
```sh
npm run dev
```conf
# TYPE DATABASE USER ADDRESS METHOD
local bb_todo bb_todo md5
```
### Compile and Minify for Production
Reload PostgreSQL config:
```sh
npm run build
systemctl postgresql reload
```
If PostgreSQL is older than version 13, you need to enable the crypto extension explicitly:
```sh
# Under (Debian) Linux, switch to the postgres user first:
# sudo su postgres
psql bb_todo
# At the # bb_todo prompt:
SELECT gen_random_uuid();
# If this prints a UUID, you're ok. If you get an error, do this:
CREATE EXTENSION pgcrypto;
# Might try the SELECT call again.
```
#### Database Schema
This repository contains an already compiled SQL file that creates the database schema:
```sh
psql -U bb_todo bb_todo < bbconf/todo_datamodel.sql
```

View File

@ -37,7 +37,7 @@ value = "'$description'"
[[resolvers.updateTask.resolver.command.modify_values]]
column = "completed"
value = "$completed"
value = "'$completed'"
[[resolvers.updateTask.resolver.command.modify_values]]
column = "list_id"
@ -127,7 +127,7 @@ value = "'$description'"
[[resolvers.createTask.resolver.command.modify_values]]
column = "completed"
value = "$completed"
value = "'$completed'"
[[resolvers.createTask.resolver.command.modify_values]]
column = "list_id"

View File

@ -40,7 +40,7 @@ realm = "todo"
client_secret = "SLnMUb4JArLs5LtzoqcQu0rg9PpgLtsN"
# Base URL to the identity provider (OAuth2/OpenID Connect server, e.g. Keycloak)
idp_url = "https://kcdev.basebox.health:8443"
idp_url = "https://kcdev.basebox.io:8443"
# OpenID Connect scope; default is "openid profile email"
scope = "openid profile email"

View File

@ -5,14 +5,14 @@ log_level = "trace"
[idp_config]
# URL of IdP's discovery endpoint. If not set, the URL is made up by appending
# ".well-known/openid-configuration" to the id_token_validation.iss field.
discovery_url = "https://kcdev.basebox.health:8443/realms/todo/.well-known/openid-configuration"
discovery_url = "https://kcdev.basebox.io:8443/realms/todo/.well-known/openid-configuration"
# URL of IdP's public keystore. If set, the discovery endpoint is not used at all.
jwks_url = "https://kcdev.basebox.health:8443/realms/todo/protocol/openid-connect/certs"
jwks_url = "https://kcdev.basebox.io:8443/realms/todo/protocol/openid-connect/certs"
[openid_token_validation]
# Incoming ID tokens are validated using, among other, the following fields.
# Contents of 'iss' field, usually the URL of the authetnication realm
iss = "https://kcdev.basebox.health:8443/realms/todo"
iss = "https://kcdev.basebox.io:8443/realms/todo"
# ID token audience field, usually OpenID Connect client ID
id_aud = "todo-app"
# Access token audience field

View File

@ -1,64 +1,179 @@
[resolvers.getUser]
operation_name = "getUser"
[resolvers.updateList]
operation_name = "updateList"
[resolvers.getUser.resolver]
command_type = "SQLSelect"
[resolvers.updateList.resolver]
command_type = "SQLUpdate"
[resolvers.updateList.resolver.command]
table = "List"
columns = []
tables = [["User", ""]]
where_clauses = [["User", "username", "= '$username'"]]
join_clauses = []
modify_table = ["", ""]
modify_values = []
aggregate_final_json_result = true
aggregate_result = true
[resolvers.deleteTask]
operation_name = "deleteTask"
[[resolvers.updateList.resolver.command.modify_values]]
column = "title"
value = "'$title'"
[resolvers.deleteTask.resolver]
command_type = "SQLDelete"
columns = []
tables = []
where_clauses = [["Task", "id", "= '$id'"]]
join_clauses = []
modify_table = ["Task", ""]
modify_values = []
aggregate_final_json_result = true
[[resolvers.updateList.resolver.command.where_clauses]]
table = "List"
column = "id"
condition_str = "= '$id'"
index = ""
[resolvers.createTask]
operation_name = "createTask"
[resolvers.createTask.resolver]
command_type = "SQLInsert"
[resolvers.createTask.resolver.command]
table = "Task"
columns = []
tables = []
where_clauses = []
join_clauses = []
modify_table = ["Task", ""]
modify_values = [["title", "'$title'"], ["description", "'$description'"], ["completed", "$completed"], ["list_id", "'$list.$id'"], ["user_username", "'$user.$username'"]]
aggregate_final_json_result = true
aggregate_result = true
[[resolvers.createTask.resolver.command.modify_values]]
column = "title"
value = "'$title'"
[[resolvers.createTask.resolver.command.modify_values]]
column = "description"
value = "'$description'"
[[resolvers.createTask.resolver.command.modify_values]]
column = "completed"
value = "$completed"
[[resolvers.createTask.resolver.command.modify_values]]
column = "list_id"
value = "'$list.$id'"
[[resolvers.createTask.resolver.command.modify_values]]
column = "user_username"
value = "'$user.$username'"
[resolvers.deleteTask]
operation_name = "deleteTask"
[resolvers.deleteTask.resolver]
command_type = "SQLDelete"
[resolvers.deleteTask.resolver.command]
table = "Task"
columns = []
modify_values = []
aggregate_result = true
[[resolvers.deleteTask.resolver.command.where_clauses]]
table = "Task"
column = "id"
condition_str = "= '$id'"
index = ""
[resolvers.createUser]
operation_name = "createUser"
[resolvers.createUser.resolver]
command_type = "SQLInsert"
[resolvers.createUser.resolver.command]
table = "User"
columns = []
where_clauses = []
aggregate_result = true
[[resolvers.createUser.resolver.command.modify_values]]
column = "username"
value = "'$username'"
[[resolvers.createUser.resolver.command.modify_values]]
column = "name"
value = "'$name'"
[resolvers.getUser]
operation_name = "getUser"
[resolvers.getUser.resolver]
command_type = "SQLSelect"
[resolvers.getUser.resolver.command]
table = "User"
columns = []
modify_values = []
aggregate_result = true
[[resolvers.getUser.resolver.command.where_clauses]]
table = "User"
column = "username"
condition_str = "= '$username'"
index = ""
[resolvers.updateTask]
operation_name = "updateTask"
[resolvers.updateTask.resolver]
command_type = "SQLUpdate"
[resolvers.updateTask.resolver.command]
table = "Task"
columns = []
tables = []
where_clauses = [["Task", "id", "= '$id'"]]
join_clauses = []
modify_table = ["Task", ""]
modify_values = [["title", "'$title'"], ["description", "'$description'"], ["completed", "$completed"], ["list_id", "'$list.$id'"]]
aggregate_final_json_result = true
aggregate_result = true
[[resolvers.updateTask.resolver.command.modify_values]]
column = "title"
value = "'$title'"
[[resolvers.updateTask.resolver.command.modify_values]]
column = "description"
value = "'$description'"
[[resolvers.updateTask.resolver.command.modify_values]]
column = "completed"
value = "$completed"
[[resolvers.updateTask.resolver.command.modify_values]]
column = "list_id"
value = "'$list.$id'"
[[resolvers.updateTask.resolver.command.where_clauses]]
table = "Task"
column = "id"
condition_str = "= '$id'"
index = ""
[resolvers.deleteList]
operation_name = "deleteList"
[resolvers.deleteList.resolver]
command_type = "SQLDelete"
[resolvers.deleteList.resolver.command]
table = "List"
columns = []
modify_values = []
aggregate_result = true
[[resolvers.deleteList.resolver.command.where_clauses]]
table = "List"
column = "id"
condition_str = "= '$id'"
index = ""
[resolvers.createList]
operation_name = "createList"
[resolvers.createList.resolver]
command_type = "SQLInsert"
[resolvers.createList.resolver.command]
table = "List"
columns = []
tables = []
where_clauses = []
join_clauses = []
modify_table = ["List", ""]
modify_values = [["title", "'$title'"], ["user_username", "'$user.$username'"]]
aggregate_final_json_result = true
aggregate_result = true
[[resolvers.createList.resolver.command.modify_values]]
column = "title"
value = "'$title'"
[[resolvers.createList.resolver.command.modify_values]]
column = "user_username"
value = "'$user.$username'"