Skip to content

mosip/mimoto

Repository files navigation

Maven Package upon a push Quality Gate Status

mimoto

Overview

This repository contains source code for backend service of Inji Mobile and Inji Web. The modules exposes API endpoints.

Build & run (for developers)

The project requires JDK 21, postgres and google client credentials

without docker-compose Build & install

  1. Install pgadmin and update application-default.properties file with values

    spring.datasource.username=
    spring.datasource.password=
  2. Configuring Cache Providers:

    By default, Mimoto uses Caffeine, a fast in-memory cache. This works well if you're running just one instance of Mimoto.

    But if you're running multiple Mimoto instances (like in Docker Swarm, Kubernetes, or a load-balanced setup), each instance has its own separate cache with Caffeine — they don’t talk to each other.

    In that case, switching to a shared cache like Redis is important. Redis lets all Mimoto instances share the same cached data, which helps keep things consistent and improves performance in distributed setups.

    For detailed setup instructions (including running Redis with Docker CLI and updating configuration), see the Cache Providers Setup Guide section.

  3. Configuring Postgres Database:

    1. Ensure Postgres Service is Available and Connected
      • Using Local Postgres Installation: If you have Postgres installed locally, run the database initialization scripts:

        cd db_scripts/inji_mimoto
        ./deploy.sh deploy.properties
      • Using Docker Compose: If you don't have postgres setup in your local you can run Postgres along with Mimoto by using the postgres service in docker-compose.yml.

      • Or, run Postgres using Docker while starting Mimoto through your IDE:

        • Use the following Docker command to start the Postgres service and expose it on the default port 5432. Make sure this port is accessible from your local machine.
              docker pull postgres:latest  # Pull the Postgres image if not already available
              docker run -d --name postgres \
              -e POSTGRES_USER=postgres \
              -e POSTGRES_PASSWORD=postgres \
              -e POSTGRES_DB=inji_mimoto \
              -p 5432:5432 \
              postgres:latest
        • Start Mimoto normally, following the instructions mentioned in Build & run (for developers) section.
    2. Update the following properties in
    1. Check data in postgres by using the following commands
      docker exec -it postgres psql -U postgres -d inji_mimoto # connect to container
      
      \dt mimoto.* # to see all tables in mimoto schema
      
      SELECT * FROM mimoto.<table_name>; # to see data in a table
  4. Refer to the How to create Google Client Credentials section to create Google client credentials and update below properties in application-local.properties.

    spring.security.oauth2.client.registration.google.client-id=
    spring.security.oauth2.client.registration.google.client-secret=
    
  5. Add identity providers as issuers in the mimoto-issuers-config.json file of resources folder. For each provider, create a corresponding object with its issuer-specific configuration. Refer to the Issuers Configuration section for details on how to structure this file and understand each field's purpose and what values need to be updated.

  6. Add or update the verifiers clientId, redirect and response Uris in mimoto-trusted-verifiers.json file of resources folder for Verifiable credential Online Sharing.

  7. Keystore(oidckeystore.p12) Configuration: In the root directory, create a certs folder and generate an OIDC client. Add the onboard client’s key to the oidckeystore.p12 file and place this file inside the certs folder. Refer to the official documentation for guidance on how to create the oidckeystore.p12 file and add the OIDC client key to it.

    • The oidckeystore.p12 file stores keys and certificates, each identified by an alias (e.g., mpartner-default-mimoto-insurance-oidc). Mimoto uses this alias to find the correct entry and access the corresponding private key during the authentication flow.
    • Update the client_alias field in the mimoto-issuers-config.json file with this alias so that Mimoto can load the correct key from the keystore.
    • Also, update the client_id field in the same file with the client_id used during the onboarding process.
    • Set the oidc_p12_password environment variable in the Mimoto service configuration inside docker-compose.yml to match the password used for the oidckeystore.p12 file.
    • Update the following properties in applicatio-local.properties file
    mosip.oidc.p12.password=<your-keystore-password>
    mosip.kernel.keymanager.hsm.config-path=<path to the keystore file>
    mosip.kernel.keymanager.hsm.keystore-pass=<your-keystore-password>
    • Mimoto also uses this same keystore file (oidckeystore.p12) to store keys generated at service startup, which are essential for performing encryption and decryption operations through the KeyManager service.
  8. To configure any Mobile Wallet specific configurations refer to the Inji Mobile Wallet Configuration section.

  9. Run the SQLs using /deploy.sh script. from db_scripts folder

    ./deploy.sh deploy.properties
    
  10. Build the jar

    mvn clean install -Dgpg.skip=true -Dmaven.javadoc.skip=true -DskipTests=true
    
  11. Run following command

    mvn spring-boot:run -Dspring.profiles.active=local
    

Cache Providers Setup Guide

To use Redis (or any other cache provider), the service must be running and accessible to Mimoto. Both services (cache provider and Mimoto) must be on the same Docker network.
This can be done by adding them to a shared network in your docker-compose.yml file, or by using the following commands if they are running separately.

Example: Using Redis as Cache Provider

  1. Ensure Redis Service is Available and Connected:

    • Using Docker Compose: You can run Redis alongside Mimoto by adding the below lines in docker-compose.yml. Docker Compose ensures both services run on the same network automatically.

      1. Add the Redis service under the services section:
         redis:
           image: redis:alpine
           container_name: 'redis'
           ports:
             - "6379:6379"
           volumes:
             - redis-data:/data
      2. Make Redis a dependency for the Mimoto service:
         mimoto-service:
           depends_on:
             - redis
      3. Add Redis data volume in the volumes section:
         volumes:
           redis-data:
    • Or, run Redis using Docker while starting Mimoto through your IDE:

      • Use the following Docker command to start the Redis service and expose it on the default port 6379. Make sure this port is accessible from your local machine.
        docker pull redis:alpine # Pull the Redis image if not already available
        docker run -d --name redis -p 6379:6379 redis:alpine  # Start a Redis container named 'redis' and expose it on port 6379
      • Start Mimoto normally, following the instructions mentioned in Build & run (for developers) section.
  2. Update the following properties in

    spring.session.store-type=redis   # Store HTTP sessions in Redis
    spring.cache.type=redis           # Store application data in Redis
  3. Add and update the required Redis configurations in

  4. Check the cached data of the redis by running the following command:

    docker exec -it redis redis-cli

with docker-compose

  1. To simplify running mimoto in local for developers we have added Docker Compose Setup. This docker-compose includes mimoto service and nginx service to server static data.
  2. Follow the below steps to use custom build image in docker-compose
  • Build the mimoto.jar mvn clean install -Dgpg.skip=true -Dmaven.javadoc.skip=true -DskipTests=true
  • Build docker image by running the below command in the directory where Dockerfile is present, use any image tag docker build -t <image-with-tag> .
  • Use newly built docker image in docker-compose file

Credits

Credits listed here

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 58