cognitoJwtVerify

package module
v0.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 26, 2025 License: Apache-2.0 Imports: 3 Imported by: 3

README

Cognito JWT Verifier

This is a simple library to verify JWT tokens issued by AWS Cognito. It is written in Go and is based on the aws-jwt-verify library.

Usage

package main

import (
    "fmt"
    "github.com/jhosan7/cognito-jwt-verify"
)

func main() {
    cognitoConfig := cognitoJwtVerify.Config{
        UserPoolId: "eu-west-1_XXXX",
        ClientId:   "xxxxx...",
        TokenUse:   "access", // id or access, if not set, it will not check the token use
    }
    
    verify, err := cognitoJwtVerify.Create(cognitoConfig)
    if err != nil {
        fmt.Println(err)
        return
    }
    
    payload, err := verify.Verify("eyJraW...")
    if err != nil {
        fmt.Printf("Error: %s\n", err)
        return
    }
    
    fmt.Println(payload)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CognitoJwtVerifier

type CognitoJwtVerifier struct {
	// contains filtered or unexported fields
}

func Create

func Create(config Config) (CognitoJwtVerifier, error)

func (CognitoJwtVerifier) Verify

func (c CognitoJwtVerifier) Verify(token string) (jwt.Claims, error)

type Config

type Config struct {
	UserPoolId string
	TokenUse   string
	ClientId   string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL