https://github.com/gemcook/gognito
AWS Cognito library for Go
https://github.com/gemcook/gognito
aws cognito-user-pool jwt
Last synced: about 2 months ago
JSON representation
AWS Cognito library for Go
- Host: GitHub
- URL: https://github.com/gemcook/gognito
- Owner: gemcook
- License: mit
- Created: 2018-05-22T11:18:23.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2023-12-15T17:45:29.000Z (over 2 years ago)
- Last Synced: 2026-04-26T19:28:07.699Z (about 2 months ago)
- Topics: aws, cognito-user-pool, jwt
- Language: Go
- Size: 8.79 KB
- Stars: 0
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# gognito
gognito provides the way to verify Cognito UserPool's JSON Web Token and handle the claims.
## Installation
```sh
go get "github.com/gemcook/gognito"
```
If you use `dep`
```sh
dep ensure -add "github.com/gemcook/gognito"
```
## Example
```go
package main
import (
"os"
"log"
"github.com/gemcook/gognito/auth"
)
func main(){
// Set Cognito UserPool information
authenticator, err := auth.New(
&auth.UserPool{
Region: os.Getenv("COGNITO_REGION"),
PoolID: os.Getenv("COGNITO_USER_POOL_ID"),
},
&auth.Option{
// [!important]
// If NoVerification option is set true, authenticator accepts NOT VALID JWT.
// That means authenticator ignores "wrong signature", "expired", "wrong issuer", and so on.
// Use this feature only for development environment.
NoVerification: false,
})
token := "eyJraW...."
// verify the token is valid.
jwt, err := authenticator.ValidateToken(token)
if err != nil {
log.Fatal("something wrong with the token")
}
// ...
}
```