npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@awesome-cdk/cdk-cognito-authentication-endpoints

v1.0.1

Published

AWS CDK construct for creating API Gateway endpoints for registration and login, powered by AWS Cognito.

Downloads

15

Readme

CDK Cognito Authentication Endpoints for API Gateway

AWS CDK construct for creating API Gateway endpoints for registration and login, powered by AWS Cognito.

Usage

const apiGateway = new apiGateway.RestApi(this, 'RestApi');

const userPool = new cognito.UserPool(this, 'UserPool');

const authResource = apiGateway.root.addResource('auth');

new CognitoAuthEndpoints(this, 'CognitoAuthEndpoints', {
    rootResource: authResource,
    userPool,
});

The final result will be, the following API endpoints will be created at the root of your API Gateway:

POST [apigatway_url]/auth/register

{
  "username": "john",
  "password": "StrongPassword!1!"
}

POST [apigatway_url]/auth/login

{
  "username": "john",
  "password": "StrongPassword!1!"
}

Why not work with Cognito directly?

  • By having a standard layer of REST APIs before your authentication provider (Cognito) you get the added benefit of being able to enforce extra middleware or afterware logic. For example, you can throttle requests or implement advanced antispam protection (reCaptcha, etc). Also, having the auth endpoints as standard REST APIs (like APIs for any other feature within your app), makes them much easier to consume by end users, instead of forcing those users to deal with the complexity of Cognito.
  • Provides slightly better security than exposing the UserPool for public access
  • No vendor lock-in. You can replace the underlaying Cognito auth service with something else and keep the REST APIs and the rest of your app's codebase intact.

Future plans:

  • [ ] Support for email OR username as the user's primary identification method
  • [ ] Forgot password. Can only work if the primary identification method is email
  • [ ] Push to EventBridge default bus of the account, so the rest of your application can react asynchronously to Registration or Login events (e.g. write newly registered users to a DynamoDB table or send them a Welcome email or keep track of login count)