Documentation
Auth

šŸ” Authentication Infrastructure

Blitzship uses Auth.js (opens in a new tab) for authentication. For it to work, we will set up a DynamoDB table that will be used to store user authentication data like tokens, sessions usernames etc. You will not interact with this table directly, it will be fully managed by Auth.js.

The auth.ts file sets up all of the necessary infrastructure that Auth.js needs to work. It creates a DynamoDB table for storing user authentication data and configures necessary IAM permissions for Auth.js to access the table.

Streaming to the primary Database

Since we want this table to only be used by Auth.js, we will use DynamoDBs capability to automatically stream changes in the auth table to our primary application table that we defined in the dynamo.ts file.

Streaming is a powerful DynamoDB features that enables a whole array of use cases. In this case, we connect a lambda function to the auth table that will be called every time something in the auth table changes. In the lambda handler code, we check if a new user has been created and if so, we create a new record in our primary database.

You can also use the streaming feature to allow any of the following use cases:

  • Syncing data between tables
  • Triggering lambda functions on data changes
  • Pushing data to Full-Text Search engines like Elasticsearch, Meilisearch, etc.
  • Pushing data to analytics tools like Mixpanel, Segment, etc.
  • etc.