Published a YouTube video
Spoke about AWS
Published a podcast episode
Live Coding

53. Authentication for a CLI app with AWS Cognito - Live coding PART 6

How can you build a WeTransfer or a Dropbox Transfer clone on AWS?

This is our sixth (and last!) live coding stream. In this episode, we completed the authentication layer for our file transfer application. Specifically, we completed the OAuth 2 device flow on top of AWS Cognito and updated the weshare CLI application to support this new authentication flow. We also added an authorization layer in front of our file upload API.

All our code is available in this repository:

🔖  Chapters:

00:00 Intro
01:54 Reviewing the last step of the OAuth 2 Device Flow (and the code changes from the PR)
09:00 Adding an authorizer to the upload API
12:00 Testing the entire device authorization flow with Postman
23:00 Updating our weshare CLI to support the device authentication flow
26:37 Failing at git (as usual)
27:50 Testing the behavior of the CLI without authentication
29:05 Splitting the CLI code into multiple files (upload, login, logout)
38:50 Defining the flow of the login command
40:40 Interactively prompting the user for a login URL with enquirer
47:40 Starting the device auth flow using undici as HTTP client
52:33 Opening the browser window using the open package and showing a spinner with the ora package
58:41 Implementing the authentication polling logic using undici
01:13:50 Persisting the tokens with the conf package
01:24:25 Implementing the logout command
01:26:00 Updating the upload command to check if we are logged in and to send the authentication header
01:30:46 Questions, final remarks & wrap up

In this episode we mentioned the following resources:
  - GitHub PR with the final OAuth 2.0 device flow step:
  - jwtinfo CLI tool:
  - enquirer package:
  - undici HTTP client package:
  - open package to open the browser at a specific URL:
  - ora: animated spinner package:
  - conf package for persisting user settings:

We set ourselves up for a challenge and in this series of live streams we will try to incrementally build a simple clone of WeTransfer or Dropbox Transfer that would allow us to upload files and share them by URL.

Everything is up for discussion (and your opinion is important!) but right now we are expecting to be using S3, Lambda, API Gateway, Route53, DynamoDB and tons of Node.js!

Come and join us on this fantastic project! 🤩

All the episodes of this series:

- 🗒 Full playlist:
- PART 1: (MVP with Lambda, API Gateway, and S3)
- PART 2: (Custom domain with Route53 and Content-Disposition)
- PART 3: (Observability best practices with Middy and Lambda Power Tools + CLI Application)
- PART 4: (Adding authentication using Cognito and implementing the OAuth 2 device flow)
- PART 5: (OAuth 2 device flow and DynamoDB Single Table Design)
- PART 6: (Completing OAuth 2 device flow and Adding a login command to the CLI application)

#aws #cli #nodejs