This page provides comprehensive documentation for the installation of spar-self-service-api, a service designed for data mapping within the Social Payments Account and Registry (SPAR) system.
Configure database credentials and other environment variables in the `.env` file
Run migrations to set up the database:
python main.py migrate
Seeding the database (Optional)
This will seed the database with default values. Make sure to update the eSignet configuration in the db as per your installation.
PostgreSQL DB Setup:
Create a new role/user called "sparuser" and create a new database called "spardb", with "sparuser" as the owner.No need to run this step if Postgres was installed through openg2p's deployment script.
CREATE ROLE sparuser WITH LOGIN NOSUPERUSER CREATEDB CREATEROLE INHERIT REPLICATION CONNECTION LIMIT -1 PASSWORD 'xxxxxx';
CREATE DATABASE spardb WITH OWNER = sparuser CONNECTION LIMIT = -1;
Then run:
cd db_scripts &&
DB_HOST="openg2p.sandbox.net" \
DB_USER_PASSWORD="xxxxxx" \
./deploy.sh && cd ..
The following optional Env vars can also be passed:
- `VERSION="1.0.0"` Do not set this if you want latest version.
- `DB_PORT="5432"` Default is 5432.
- `DB_NAME="mydb"` Default is spardb.
- `DB_USER="myuser"` Default is sparuser.
- `DEPLOY_DML="false"` Default is true. If false, will not run DML scripts.
- `LOG_DB_QUERY="true"` Default is false. Logs all Db queries.
Quick Start
Start the development server
python main.py run
Access Swagger API Documentation
Configuration
Environment Variables
Set the following environment variables to configure the `spar-mapper-api`:
# Database credentials for spar-mapper-api (Update these values as per your installation/setup)
SPAR_SELFSERVICE_DB_DBNAME=openg2p_spar_db
SPAR_SELFSERVIC_DB_HOSTNAME='localhost'
SPAR_SELFSERVIC_DB_USERNAME='sparuser'
# Auth (Update these values as per your installation/setup)
SPAR_SELFSERVICE_AUTH_DEFAULT_ISSUERS=[ "https://esignet.dev.sandbox.net/v1/esignet", "https://keycloak.dev.sandbox.net/realms/sandbox" ]
SPAR_SELFSERVICE_AUTH_DEFAULT_JWKS_URLS=[ "https://esignet.dev.sandbox.net/v1/esignet/oauth/.well-known/jwks.json", "https://keycloak.dev.sandbox.net/realms/sandbox/protocol/openid-connect/certs" ]
# SPAR Mapper API Endpoints (change only if required)
SPAR_SELFSERVICE_MAPPER_API_URL="http://localhost:8007/sync"
SPAR_SELFSERVICE_MAPPER_LINK_PATH="/link"
SPAR_SELFSERVICE_MAPPER_UNLINK_PATH="/unlink"
SPAR_SELFSERVICE_MAPPER_RESOLVE_PATH="/resolve"
SPAR_SELFSERVICE_MAPPER_UPDATE_PATH="/update"
Authentication
Testing
To run unit tests with pytest:
pytest -s
Contributing
The spar-self-service-api supports authentication via eSignet. Refer to the deployment documentation for eSignet for setup instructions.