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

51. Authentication for a CLI app with Cognito - Live coding PART 4

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

This is our fourth live coding stream. In this episode, we started looking into adding some security to our application. Specifically, we started implementing a device auth flow on top of AWS Cognito to allow our file upload CLI application to get some credentials.

All our code is available in this repository:

🔖  Chapters:

00:00 Intro
04:10 Intro to Cognito
06:47 Difference between User Pools and Identity Pools (Federated Identities)
10:52 High-level view of how OAuth 2 works (implicit flow)
14:55 How can we get tokens for CLI Apps using OAuth 2 / OIDC Connect?
18:20 OAuth 2 device code authorization flow (RFC 8628)
22:40 Device authorization request
26:50 User login and polling
29:50 Verification and token retrieval
39:17 Improvements from the previous version of the code (content-disposition sanitization and more)
47:57 Implementing the OAuth 2 Device code flow using serverless
50:42 Defining a Cognito User Pool in serverless.yml
56:50 Defining the OAuth 2 Client for our application in serverless.yml
1:07:58 Deploying our changes and reviewing the generated resources (and debugging 😅)
1:15:10 Creating environment variables and SSM parameters for easy access to Cognito details
1:21:10 Creating a stub of our Lambda function to handle requests for device auth
1:30:00 Wrapping up

In this episode we mentioned the following resources:
  - Content-Disposition Header on MDN:
  - OAuth 2 Device Auth flow RFC8628:
  - XKCD Comic about password security:
  - crypto-random-string package:
  - Dash offline documentation app:

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, and tons of Node.js!

Come and join us on this awesome 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 #Cognito #Serverless