Giter Site home page Giter Site logo

go-cognito-jwt-validator's Introduction

A Simple Go library that validates AWS cognito JWT token


๐Ÿ—๏ธ Installation

  # Add to your go project using:
  go get github.com/eryk-vieira/go-cognito-jwt-validator

๐Ÿง‘โ€๐Ÿ’ป Usage

package main

import (
  validator "github.com/eryk-vieira/go-cognito-jwt-validator"
)

func main(){
  // Change the config with your valid credentials
  validator := validator.New(&validator.Config{
      	  Region:          "AWS Cognito Region",
	  CognitoPoolId:   "Cognito Pool Id",
	  CognitoClientId: "Cognito Client Id",
  })
  
  err := validator.Validate("JWT Token")

  // if err != nil your Token is invalid, expired or don't follow any of yout public keys signature
  if err != nil {
    fmt.Println(err)
  }
}

๐Ÿ“• License

Released in 2022. This project is under the MIT license ๐Ÿš€

Made with love by Eryk ๐Ÿš€

go-cognito-jwt-validator's People

Contributors

eryk-vieira avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

go-cognito-jwt-validator's Issues

Issue in validating client_id

Below code throws error of interface conversion as aws now gives client_id as key and you can directly get it from the token 
    claims hence below code is invalid as the token now has client_id
    Can i generate a pull request ?

clientId, _ := parsedToken.Get("aud")
token_use, _ := parsedToken.Get("token_use")

if clientId.([]string)[0] != config.CognitoClientId {
	return errors.New("TOKEN IS FROM A DIFFERENT client_id")
}

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.