Socket
Socket
Sign inDemoInstall

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

Package Overview
Dependencies
8
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

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

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


Version published
Maintainers
1
Created

Readme

Source

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)

FAQs

Last updated on 22 Sep 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc