ytgov / signing-authority

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Development

1. Configure Environment Variables

2. Bring up MongoDB

From the root of the project directory run:

 docker compose --env-file ./.env.development --file docker-compose.dev.yaml up --build

3. Bring up API Server

From the root of the project directory run:

cd signing-authority/api/
npm run start

By default, this will bring up an instance of the API server on port 3000. The API server will automatically reload on save.

Note: changes to .env variables require a shutdown and restart to server to take effect.

4. Bring up API Front End Server

From the root of the project directory run:

cd signing-authority/web/
npm run start

By default, this will bring up an instance of the front end server on port 8080.

Note: changes to .env variables require a shutdown and restart to server to take effect.

5. Confirm dev environment

To confirm the environment is working properly, navigate to: [http://localhost:8080/administration]http://localhost:8080/administration

5. Seed data (optional)

Run using prebuilt images

Stand up a version of the app using prebuilt images:

docker compose --env-file ./.env.development --file docker-compose.dev.yaml up --build

Production

The production environment builds and deploys two containers, a Mongo database server and a front end Node/Express app which serves the front end and the api services. For persistent storage, a docker volume is created as part of the process. One the build process is complete and the containers are deployed you can reach the app at https://:3000/public

Build and Run the Prodcuction Containers

docker compose --env-file ./.env.production up -d --build

Stop Containers

To stop the container run but leave the database storage volume intact, run:

docker compose --env-file ./.env.production down

To stop the container and remove the database storage volume run:

docker compose --env-file ./.env.production down -v


Project Structure

Single project that builds into two containers.

Backend

Root: <project_root>/api

Technology:

  • Node
  • Express
  • TypeScript
  • JWT based authentication

Auth: Authenticated routes use JWT tokens. Secure routes with RequiresAuthentication middleware.

Frontend

Root: <project_root>/web

Layouts

Reusable application layouts are defined in /web/src/layouts. Modules must embed their views and components in a layout

Modules

Each logical section of the appplication is broken into modules. Modules are defined in /web/src/modules.

Modules contain all the Vue code needed for the modules including:

  • store (vuex)
  • routes (vue-router)
  • componenents
  • views

Authentication

Authenication is done with JWTs. It is handled by a plugin defined in ./web/src/auth/auth0-plugin.js. The first time the application loads it will atempt to silently log the user in via getTokenSilently(). If that fails, the users will be redirected to a login process. Note: it can take up to 30 seconds to complete the authentication process.

Authentication information is available anywhere in the Vue frontend via a call to this.$auth.

$auth.user

  • returns information about the currently logged in user

$auth.isAuthenticated

  • returns true if the user is authenticated

Azure AD Authentication

User can authenticate using their corporate account. This is handed via federation in the backend authentication configuration.

Clearing out the MongoDB collecions from a command line

docker exec -it <docker_container_name> bash

use authorities

show collections

db.runCommand({count: 'PositionGroups'})
db.PositionGroups.remove({})

db.runCommand({count: 'Authorities'})
db.Authorities.remove({})

db.runCommand({count: 'FormA'})
db.FormA.remove({})

db.runCommand({count: 'SAA-FILES.chunks'})
db['SAA-FILES.chunks'].remove({})

db.runCommand({count: 'SAA-FILES.files'})
db['SAA-FILES.files'].remove({})

Upgrading from MongoDB 5 to 6

Upgrade MongoDB docker image from version tag mongo:5.0.6 to mongo:6.0

Database server should start just fine and run no problem.

Exec into running MongoDB container and open mongosh to move compatibitlity version from 5 to 6

docker exec -it <docker_container_name> bash
mongosh --username admin
db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } )
db.adminCommand( { setFeatureCompatibilityVersion: "6.0" } )

Upgrading from MongoDB 6 to 7

Upgrade MongoDB docker image from version tag mongo:6.0 to mongo:7.0

Database server should start just fine and run no problem.

Exec into running MongoDB container and open mongosh to move compatibitlity version from 6 to 7

docker exec -it <docker_container_name> bash
mongosh --username admin
db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } )
db.adminCommand( { setFeatureCompatibilityVersion: "7.0", confirm: true } )

About


Languages

Language:Vue 50.2%Language:TypeScript 31.9%Language:HTML 9.2%Language:JavaScript 8.1%Language:CSS 0.4%Language:Dockerfile 0.2%