Skip to content

Instantly share code, notes, and snippets.

View stream-jdibling's full-sized avatar

John Dibling stream-jdibling

  • 19:35 (UTC -05:00)
View GitHub Profile
@stream-jdibling
stream-jdibling / auth.go
Last active December 1, 2022 12:25 — forked from miguelmota/auth.go
Golang AWS Cognito Validate JWT token
/* This algorithm is based off of the AWESOME gist by miguelmota:
https://gist.github.com/miguelmota/06f563756448b0d4ce2ba508b3cbe6e2
However that code had two problems -
1) It used a deprecated jwt library (github.com/dgrijalva/jwt-go). The code below uses the current implementation at github.com/golang-jwt/jwt/v4
2) The KeyFunc closure passed to jwt.Parse() always used the second JWK, even if the KID in the JWT header pointed to a different JWK. The code below finds the JWK for the KID specified in the header and verifies against that.
*/