Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-gin-cognito-jwt-verification

A Go/Gin application demonstrating Cognito JWT verification middleware. Incoming requests to protected routes must carry a valid Authorization: Bearer <token> header. The middleware verifies the JWT against Cognito's public JWKS endpoint.

Getting Started

mise manages the pinned toolchain (Go 1.26, golangci-lint).

# macOS / Linux
curl https://mise.run | sh

# Windows
winget install jdx.mise

Activate mise in your shell (~/.zshrc):

eval "$(mise activate zsh)"

Then, in the repo:

mise trust    # one-time
mise install  # downloads Go and golangci-lint

Create a .env file at the root of the project:

AWS_DEFAULT_REGION=us-east-1
COGNITO_USER_POOL_ID=us-east-1_XXXXXXXXX
COGNITO_APP_CLIENT_ID=XXXXXXXXXXXXXXXXXXXXXXXXXX

Start the server:

mise run dev

Routes

Method Path Auth required
GET /healthcheck No
GET /protected-with-id-token Cognito ID token
GET /protected-with-access-token Cognito access token

Development

Command Description
mise run dev Run without building a binary
mise run build Build the Go binary
mise run test Run tests
mise run fmt Format code via golangci-lint fmt
mise run lint Lint via golangci-lint run
mise run vuln Scan dependencies for known vulnerabilities
mise run deps Update and tidy dependencies
mise run clean Remove build artifacts

About

Example implementation of Cognito JWT verification using Go and Gin

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages