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) [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 ### PostgreSQL Preparation
npm install
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 ```conf
npm run dev # TYPE DATABASE USER ADDRESS METHOD
local bb_todo bb_todo md5
``` ```
### Compile and Minify for Production Reload PostgreSQL config:
```sh ```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]] [[resolvers.updateTask.resolver.command.modify_values]]
column = "completed" column = "completed"
value = "$completed" value = "'$completed'"
[[resolvers.updateTask.resolver.command.modify_values]] [[resolvers.updateTask.resolver.command.modify_values]]
column = "list_id" column = "list_id"
@ -127,7 +127,7 @@ value = "'$description'"
[[resolvers.createTask.resolver.command.modify_values]] [[resolvers.createTask.resolver.command.modify_values]]
column = "completed" column = "completed"
value = "$completed" value = "'$completed'"
[[resolvers.createTask.resolver.command.modify_values]] [[resolvers.createTask.resolver.command.modify_values]]
column = "list_id" column = "list_id"

View File

@ -40,7 +40,7 @@ realm = "todo"
client_secret = "SLnMUb4JArLs5LtzoqcQu0rg9PpgLtsN" client_secret = "SLnMUb4JArLs5LtzoqcQu0rg9PpgLtsN"
# Base URL to the identity provider (OAuth2/OpenID Connect server, e.g. Keycloak) # 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" # OpenID Connect scope; default is "openid profile email"
scope = "openid profile email" scope = "openid profile email"

View File

@ -5,14 +5,14 @@ log_level = "trace"
[idp_config] [idp_config]
# URL of IdP's discovery endpoint. If not set, the URL is made up by appending # 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. # ".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. # 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] [openid_token_validation]
# Incoming ID tokens are validated using, among other, the following fields. # Incoming ID tokens are validated using, among other, the following fields.
# Contents of 'iss' field, usually the URL of the authetnication realm # 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 token audience field, usually OpenID Connect client ID
id_aud = "todo-app" id_aud = "todo-app"
# Access token audience field # Access token audience field

View File

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