kych

OAuth 2.0 API for Swiyu to enable Taler integration of Swiyu for KYC (experimental)
Log | Files | Refs

commit ab7dc9432feec1f6a6303ef1c98d3d2a4b60857a
parent 878191e63efc53b159f4b4e89a43410af68db638
Author: Henrique Chan Carvalho Machado <henriqueccmachado@tecnico.ulisboa.pt>
Date:   Tue, 25 Nov 2025 20:24:23 +0100

remove old setup scripts, add new un/install db scripts

Diffstat:
Doauth2_gateway/scripts/setup_test_db.sh | 81-------------------------------------------------------------------------------
Doauth2_gateway/scripts/teardown_test_db.sh | 30------------------------------
Mswiyu-verifier/api_requests/request_over_18.json | 3+++
Dswiyu-verifier/scripts/drop.sh | 3---
Dswiyu-verifier/scripts/run.sh | 17-----------------
Dswiyu-verifier/scripts/setup.sh | 41-----------------------------------------
6 files changed, 3 insertions(+), 172 deletions(-)

diff --git a/oauth2_gateway/scripts/setup_test_db.sh b/oauth2_gateway/scripts/setup_test_db.sh @@ -1,81 +0,0 @@ -#!/bin/bash - -DB_PORT=5432 -DB_NAME=oauth2gw -DB_USER=oauth2gw -DB_PASS=password -DB_ADMIN=${DB_ADMIN:-} - -echo "Setting up PostgreSQL database for OAuth2 Gateway test environment..." -echo -echo "WARNING: Test Environment!" -echo - -if ! command -v psql &> /dev/null -then - echo "psql could not be found, please install PostgreSQL first." - exit 1 -fi - -if ! pg_isready -h localhost -p "$DB_PORT" >/dev/null 2>&1; then - echo "PostgreSQL is not running." - exit 1 -fi - -PSQL_CMD="psql -h localhost -p $DB_PORT" -if [ -n "$DB_ADMIN" ]; then - PSQL_CMD="$PSQL_CMD -U $DB_ADMIN" -fi - -$PSQL_CMD -d postgres -tc "SELECT 1 FROM pg_roles WHERE rolname='$DB_USER'" | grep -q 1 || \ -$PSQL_CMD -d postgres -c "CREATE USER $DB_USER WITH PASSWORD '$DB_PASS';" - -$PSQL_CMD -d postgres -tc "SELECT 1 FROM pg_database WHERE datname='$DB_NAME'" | grep -q 1 || \ -$PSQL_CMD -d postgres -c "CREATE DATABASE $DB_NAME OWNER $DB_USER;" - -$PSQL_CMD -d "$DB_NAME" -c "GRANT ALL PRIVILEGES ON DATABASE $DB_NAME TO $DB_USER;" - -DB_URL="postgresql://${DB_USER}:${DB_PASS}@localhost:${DB_PORT}/${DB_NAME}" - -MIGRATIONS_DIR="$(dirname "$0")/../oauth2_gatewaydb" -$PSQL_CMD -d "$DB_NAME" -f "$MIGRATIONS_DIR/versioning.sql" - -echo "Applying database patches..." -for patch_file in "$MIGRATIONS_DIR"/oauth2gw-*.sql; do - if [ -f "$patch_file" ]; then - patch_name=$(basename "$patch_file" .sql) - echo "Applying patch: $patch_name" - $PSQL_CMD -d "$DB_NAME" -f "$patch_file" 2>&1 | grep -v "Patch .* is already applied" || true - fi -done - -$PSQL_CMD -d "$DB_NAME" -c "GRANT USAGE ON SCHEMA oauth2gw TO $DB_USER;" -$PSQL_CMD -d "$DB_NAME" -c "GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA oauth2gw TO $DB_USER;" -$PSQL_CMD -d "$DB_NAME" -c "GRANT USAGE, SELECT ON ALL SEQUENCES IN SCHEMA oauth2gw TO $DB_USER;" -$PSQL_CMD -d "$DB_NAME" -c "ALTER DEFAULT PRIVILEGES IN SCHEMA oauth2gw GRANT SELECT, INSERT, UPDATE, DELETE ON TABLES TO $DB_USER;" -$PSQL_CMD -d "$DB_NAME" -c "ALTER DEFAULT PRIVILEGES IN SCHEMA oauth2gw GRANT USAGE, SELECT ON SEQUENCES TO $DB_USER;" - -echo "Seeding test data" -$PSQL_CMD -d "$DB_NAME" <<EOF -INSERT INTO oauth2gw.clients (client_id, secret_hash, webhook_url, verifier_url, verifier_management_api_path) -VALUES ( - 'test-exchange', - 'test-secret-123', - 'http://localhost:9090/kyc/webhook', - 'http://localhost:8080', - '/management/api/verifications' -) -EOF - -echo "Setup completed." -echo -echo "Database: $DB_NAME" -echo "User: $DB_USER" -echo "Host: localhost" -echo "Port: $DB_PORT" -echo -echo "Connection string:" -echo " $DB_URL" -echo -echo "Set TEST_DATABASE_URL environment variable:" -echo " export TEST_DATABASE_URL=\"$DB_URL\"" diff --git a/oauth2_gateway/scripts/teardown_test_db.sh b/oauth2_gateway/scripts/teardown_test_db.sh @@ -1,30 +0,0 @@ -#!/bin/bash - -DB_PORT=5432 -DB_NAME=oauth2gw -DB_USER=oauth2gw -DB_ADMIN=${DB_ADMIN:-} - -echo "Tearing down OAuth2 Gateway test database..." -echo - -if ! command -v psql &> /dev/null -then - echo "psql could not be found, please install PostgreSQL first." - exit 1 -fi - -if ! pg_isready -h localhost -p "$DB_PORT" >/dev/null 2>&1; then - echo "PostgreSQL is not running." - exit 1 -fi - -PSQL_CMD="psql -h localhost -p $DB_PORT" -if [ -n "$DB_ADMIN" ]; then - PSQL_CMD="$PSQL_CMD -U $DB_ADMIN" -fi - -DB_DIR="$(dirname "$0")/../oauth2_gatewaydb" -$PSQL_CMD -d "$DB_NAME" -f "$DB_DIR/drop.sql" - -echo "Teardown completed." diff --git a/swiyu-verifier/api_requests/request_over_18.json b/swiyu-verifier/api_requests/request_over_18.json @@ -1,4 +1,7 @@ { + "accepted_issuer_dids": [ + "did:tdw:QmPEZPhDFR4nEYSFK5bMnvECqdpf1tPTPJuWs9QrMjCumw:identifier-reg.trust-infra.swiyu-int.admin.ch:api:v1:did:9a5559f0-b81c-4368-a170-e7b4ae424527" + ], "jwt_secured_authorization_request": true, "response_mode": "direct_post", "response_type": "vp_token", diff --git a/swiyu-verifier/scripts/drop.sh b/swiyu-verifier/scripts/drop.sh @@ -1,3 +0,0 @@ -#!/bin/bash -dropdb verifier_db -dropuser verifier_user diff --git a/swiyu-verifier/scripts/run.sh b/swiyu-verifier/scripts/run.sh @@ -1,16 +0,0 @@ -#!/bin/bash - -# using swiyu's mvn wrapper (mvnw). -if [ -z "$(find verifier-application/target -maxdepth 1 -name '*.jar' -type f 2>/dev/null)" ]; then - echo "Building the project..." - ./mvnw clean install -DskipTests -fi - -if [ "$1" == "-d" ]; then - echo "Running in debug mode..." - ./mvnw spring-boot:run -pl verifier-application -Dspring-boot.run.profiles=local-dockerless -Dspring-boot.run.fork=true -Dspring-boot.run.jvmArguments="-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005" - exit 0 -fi - -echo "Running the application..." -./mvnw spring-boot:run -pl verifier-application -Dspring-boot.run.profiles=local-dockerless -\ No newline at end of file diff --git a/swiyu-verifier/scripts/setup.sh b/swiyu-verifier/scripts/setup.sh @@ -1,41 +0,0 @@ -#!/bin/bash - -DB_PORT=5432 -DB_NAME=verifier_db -DB_USER=verifier_user -DB_PASS=secret -DB_ADMIN=${DB_ADMIN:-} - -echo "Setting up PostgreSQL database for verifier application..." -echo -echo "WARNING: Test Environment!" -echo - -if ! command -v psql &> /dev/null -then - echo "postgresql@15 could not be found, please install it first." - exit 1 -fi - -if ! pg_isready -h localhost -p "$DB_PORT" >/dev/null 2>&1; then - echo "PostgreSQL is not running." - exit 1 -fi - -PSQL_CMD="psql -h localhost -p $DB_PORT" -if [ -n "$DB_ADMIN" ]; then - PSQL_CMD="$PSQL_CMD -U $DB_ADMIN" -fi - -# Create user if not exists -$PSQL_CMD -d postgres -tc "SELECT 1 FROM pg_roles WHERE rolname='$DB_USER'" | grep -q 1 || \ -$PSQL_CMD -d postgres -c "CREATE USER $DB_USER WITH PASSWORD '$DB_PASS';" - -# Create database if not exists -$PSQL_CMD -d postgres -tc "SELECT 1 FROM pg_database WHERE datname='$DB_NAME'" | grep -q 1 || \ -$PSQL_CMD -d postgres -c "CREATE DATABASE $DB_NAME OWNER $DB_USER;" - -# Grant privileges -$PSQL_CMD -d "$DB_NAME" -c "GRANT ALL PRIVILEGES ON DATABASE $DB_NAME TO $DB_USER;" - -echo "Setup completed."