Git Product home page Git Product logo

cognitocurl's Introduction

cognitocurl 🔏

This is CLI tool that allows you to easily sign curl calls to API Gateway with Cognito authorization token.

npm version

Why?

AWS Cognito is really powerful, especially combined with API Gateway, but if you use Cognito Authorizer or Lambda Authorizer based on Authorization header, you may encounter a problem with signing curl calls - this is why we created cognitocurl - it is tiny CLI tool made with Node.js that takes care of signing in against user pool, persisting and rotating tokens, and adding additional header to your curl call.

Made with ❤️ in Nordcloud

Usage

Installation:

$ npm i -g cognitocurl

Then:

$ cognitocurl --cognitoclient XXX --userpool YYY --run "full curl command here"

or

$ cognitocurl --hostedui hosteduisetupfilename.json --run "full curl command here"

Getting access token with a single command

$ cognitocurl --cognitoclient CLIENT_ID --userpool USER_POOL_ID --token --username USER_NAME --password USER_PASSWORD

Available flags

Tools:

  • --version
  • --help

Features:

  • --cognitoclient cognitoclientid - Cognito Client ID
  • --userpool userpoolid - Cognito User Pool ID
  • --header header - Defaults to 'Authorization'
  • --reset - Reset cached Cognito credentials
  • --run "runcommand" - pass your curl command here
  • --hostedui hostedui.json - if passed, Congito Hosted UI will be launched and configured using setup from provided json file
  • --token - if passed, run command will be ignored and access token will be printed to stdout instead
  • --username - if not passed, you will be prompted to enter a username (added to cli authentication)
  • --password - if not passed, you will be prompted to enter a password (added to cli authentication)

Hosted UI json setup example

If you want to use hosted ui, provide --hostedui. You should provide a setup jsonfile file like this:

{
  "region": "eu-west-1",
  "userPoolId": "your_user_pool_id",
  "userPoolWebClientId": "your_web_client_id",
  "redirectSignIn": "http://localhost:3000",
  "redirectSignOut": "http://localhost:3000",
  "domain": "your_hosted_ui_domain"
}

Note that lochalhost:3000 should be added to your Cognito User Pool App Client setup!

Plans for the future

  • add federated/social logins (by opening browser window)

Authors

  • Jakub Holak, Nordcloud 🇵🇱

Credits

Done using oclif. Inspired by AWS Amplify.

cognitocurl's People

Contributors

a-ostretsova avatar dependabot[bot] avatar elgordino avatar khola avatar nascit avatar smcgrath avatar tdi avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.