# Packages
No description provided by the author
# README
authjsgo
This is a package that aims to decode jwt produced using authjs only for auth.js or nextauth v5
example: config my auth.js
const option = {
// other configuratin
session: { strategy: 'jwt', maxAge : 120 }, // 2 minute expired
cookies: {
sessionToken: {
name: `mywebsite.session-token`, //session name token
options: {
httpOnly: false,
sameSite: 'none',
path: '/',
secure: true,
},
}
},
}
documentation jwt authjs
Usage: ignore expired
package main
import (
"github.com/ajipaon/authjsgo"
"encoding/json"
"fmt"
)
func main() {
token := "your token"
secret := []byte("your secret")
salt := []byte("mywebsite.session-token") // use session name
payload, _ := authjsgo.DecodeJWT(token, secret, salt, true)
var claims map[string]interface{}
if err := json.Unmarshal(payload, &claims); err != nil {
fmt.Println("Error decode json:", err)
return
}
fmt.Println(claims)
}
Usage: with expired
package main
import (
"github.com/ajipaon/authjsgo"
"encoding/json"
"fmt"
)
func main() {
token := "your token"
secret := []byte("your secret")
salt := []byte("mywebsite.session-token") // use session name
payload, _ := authjsgo.DecodeJWT(token, secret, salt)
var claims map[string]interface{}
if err := json.Unmarshal(payload, &claims); err != nil {
fmt.Println("Error decode json:", err)
return
}
fmt.Println(claims)
}
Installation
go get github.com/ajipaon/authjsgo