PDA WEB - PDA-Open-Source/PDA-SESSION GitHub Wiki

Prerequisites

  • Python 3
  • Git
  • Pip3
  • virtualenv
  • PostgreSQL

Installation

Note: Before installing the PDA-WEB application, we need to make PDA-IAM, PDA-ENTITY, PDA-IAM services up and run which would create the necessary Databases required for PDA-WEB. Create 2 AWS buckets one private and one public.

A step by step process to set up PDA- WebApp, Get the application from the git repository.

git clone https://github.com/PDA-Open-Source/PDA-WEB.git

Create a virtual environment using virtualenv and activate the environment.

virtualenv env
source env/bin/activate

Installing the necessary packages required for the project.

cd PDA-WEB
pip3 install -r requirements.txt

Configuration

This section includes database configuration, AWS S3 configuration, Vimeo configuration, and some basic Django configurations.

Let's create file .env in the current working directory copy the content from .example.env to .env file.

Now let us see what the environment variable has been used in .env file for the configuration.

Configuring the PDA Entity Database to the web application.

DB_NAME="" # The Name of the Entity Database
DB_USER="" # The Username of the Entity Database
DB_PASSWORD="" # The Password of the Entity Database
DB_HOST="" # The Host of the Entity Database
DB_PORT="" # The Post of the Entity Database

Configuring the PDA Session Database to the current application.

SESSION_DB_NAME="" # The Name of the Session Database
SESSION_DB_USER="" # The Username of the Session Database
SESSION_DB_PASSWORD="" # The Password of the Session Database
SESSION_DB_HOST="" # The Host of the Session Database
SESSION_DB_PORT="" # The Port of the Session Database

Configuring AWS S3 service to the application.

AWS_ACCESS_KEY_ID="" # Your AWS access key ID
AWS_SECRET_ACCESS_KEY="" # Your AWS secret access key
AWS_STORAGE_BUCKET_NAME="" # Your AWS storage public bucket name
AWS_REGION_NAME="" # Your AWS region name
aws_s3_bucket_name_private=""  # Your AWS storage private bucket name
aws_s3_url_private=""    # Your AWS storage private bucket url

Configuring Vimeo to the application.

VIMEO_ACCESS_TOKEN= "" # Your VIMEO access token

We can configure salt-value,iv-value and secret-key in PDA-WEB/apps/authentication/static/js/custom/encrypt.js and same thing can be copied to PDA-IAM service.

Routing Configuration

We can use Nginx to configure routing to all the services and even we can use API Gateway like Kong and other similar services to configure the routing.

Edit /etc/nginx/sites-enabled/default file and place the below configuration to the file and restart Nginx service.

location /auth/ {
        #Keycloak endpoint
        proxy_pass http://127.0.0.1:8080/auth/;
}

location /session/ {
        #PDA-SERVICE service endpoint
        proxy_pass http://127.0.0.1:9091/api/v2/session/;
}

location /user/ {
        #PDA-IAM service endpoint
        proxy_pass http://127.0.0.1:9090/api/v2/user/;
}

location /entity/ {
        #PDA-ENTITY service endpoint
        proxy_pass http://127.0.0.1:9092/api/v1/entity/;
}

location /attestations/ {
        proxy_pass http://127.0.0.1:9092/api/v1/attestations/;
}

location /template/ {
        proxy_pass http://127.0.0.1:9092/api/v1/template/;
}

Now let us collect all the static files to the STATIC_ROOT folder by running the following command.

Note: No need to run any Database migrations as we are using other services to create the necessary database tables required for the application

python3 manage.py collectstatic

Let us run the application using runserver command on the required port.

python3 manage.py runserver

Check the application http://localhost:9000 on the browser to check the application is up and running.

creating super admin in the application

  • Register a new user to the system.
  • Go to keycloak dashboard
  • Click on the user Tab.
  • Select A user for which you want to give SUPER-ADMIN access.
  • Go to role mappings tab inside the user tab.
  • Select admin from available roles tab and press Add selected button below.

Adding Coutry code to registry

First, Let's create keycloak access token using rest-client

REQUEST URI:{KEYCLOAK BASE URL}/realms/master/protocol/openid-connect/token REQUEST METHOD:POST BODY:

FORM-DATA:
         grant_type:password
         username:{}
         client_id:{}
         client_secret:{}
         password:{}

REQUEST URI:{RegistryBASEURL}/add

REQUEST METHOD:POST

HEADERS: Content-Type:application/json x-authenticated-user-token:{keycloak_access_token}

BODY:

{
   "id": "open-saber.registry.create",
   "ver": "1.0",
   "ets": 1574408022522,
   "params": null,
   "request": {
       "CountryCode":{
           "country": "INDIA",
           "code": "+91",
           "phoneNumberSizeMax": 10,
           "phoneNumberSizeMin": 10,
           "phoneNumberLength": 10
       }
   }
}