mirror of
https://github.com/idanoo/GoScrobble
synced 2025-07-01 13:42:20 +00:00
Issue JWT on login
This commit is contained in:
parent
12f4fb6d89
commit
c67be1bd75
9 changed files with 249 additions and 27 deletions
|
@ -3,6 +3,9 @@ package main
|
|||
import (
|
||||
"log"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"git.m2.nz/go-scrobble/internal/goscrobble"
|
||||
"github.com/joho/godotenv"
|
||||
|
@ -17,6 +20,21 @@ func main() {
|
|||
// Store JWT secret
|
||||
goscrobble.JwtToken = []byte(os.Getenv("JWT_SECRET"))
|
||||
|
||||
// Store JWT expiry
|
||||
goscrobble.JwtExpiry = 86400
|
||||
jwtExpiryStr := os.Getenv("JWT_EXPIRY")
|
||||
if jwtExpiryStr != "" {
|
||||
i, err := strconv.ParseFloat(jwtExpiryStr, 64)
|
||||
if err != nil {
|
||||
panic("Invalid JWT_EXPIRY value")
|
||||
}
|
||||
|
||||
goscrobble.JwtExpiry = time.Duration(i) * time.Second
|
||||
}
|
||||
|
||||
// Ignore reverse proxies
|
||||
goscrobble.ReverseProxies = strings.Split(os.Getenv("REVERSE_PROXIES"), ",")
|
||||
|
||||
// // Boot up DB connection for life of application
|
||||
goscrobble.InitDb()
|
||||
defer goscrobble.CloseDbConn()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue