Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Stages

There are 3 environments (stages) in the infrastructure, namely dev (short for development), staging (for staging) and prod (short for production). Practically, these environments should be isolated from each other.

Gateway

The gateway provides a unified entry point for all the services provided by the company. It works as a router for different services based on the route. Usually, a gateway can provide functionalities of authentication, authorization, load balancing, etc. In our infrastructure, we are using API Gateway HTTP API provided by AWS to route your services. (Read more: https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-basic-concept.html)

Authentication

The authentication has already been implemented and integrated into the gateway. When you deploy your service, you can should use it to protect your service. The authentication method being used is a typical JWT token-based authentication.

...

Expand
titleClick here to see an example of token verification.

A valid request header for a protected resource should include this below.

Code Block
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3QiLCJncm91cCI6InRlc3QiLCJleHAiOjE2NzcyMTExMjMsIm5iZiI6MTY3NzEyNDcyMywiaWF0IjoxNjc3MTI0NzIzLCJpc3MiOiJnYXRld2F5IiwiZW52IjoiZGV2In0.UVwjnRXTQnJ9Ig_24MGUZR4SWxrRq82fKGy_G64EJkI

When successful, you will receive a response like this below.

Code Block
languagejson
{
  "isAuthorized":true,
  "context":{
    "user":{
      "username":"test",
      "group":"test",
      "exp":1677211782,
      "nbf":1677125382,
      "iat":1677125382,
      "iss":"gateway",
      "env":"dev"
    }
  }
}

Services

In order to adapt your service to be run under our infrastructure, your services should be one or a set of lambda functions, or a container. Below are some examples of services.

...