mirror of
https://git.freecumextremist.com/grumbulon/pomme.git
synced 2024-11-23 02:03:47 +00:00
24 lines
400 B
Go
24 lines
400 B
Go
package api
|
|
|
|
import (
|
|
"log"
|
|
|
|
"github.com/go-chi/jwtauth/v5"
|
|
)
|
|
|
|
var tokenAuth *jwtauth.JWTAuth
|
|
|
|
const secret = "piss"
|
|
|
|
func init() {
|
|
tokenAuth = jwtauth.New("HS256", []byte(secret), nil)
|
|
}
|
|
|
|
func makeToken(username string) string {
|
|
_, tokenString, err := tokenAuth.Encode(map[string]interface{}{"username": username, "admin": "false"})
|
|
if err != nil {
|
|
log.Fatalln(err)
|
|
}
|
|
|
|
return tokenString
|
|
}
|