-
Notifications
You must be signed in to change notification settings - Fork 0
/
jwt.go
39 lines (32 loc) · 804 Bytes
/
jwt.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package model
import (
"os"
"time"
//OS ENV taken from file
_ "github.com/joho/godotenv/autoload"
jwt "github.com/dgrijalva/jwt-go"
)
var (
issuer = ""
secret = ""
authduration = 1 * time.Hour
refreshduration = 24 * 7 * time.Hour
)
func init() {
issuer = os.Getenv("JWT_ISSUER")
secret = os.Getenv("JWT_SECRET")
dur, err := time.ParseDuration(os.Getenv("JWT_AUTH_DURATION"))
if err == nil {
authduration = dur
}
refreshduration, err = time.ParseDuration(os.Getenv("JWT_REFRESH_DURATION"))
if err == nil {
refreshduration = dur
}
}
//AuthClaims custom claims to be embedded in Auth Token
type AuthClaims struct {
jwt.StandardClaims
CSRFToken string `json:"csrf,omitempty"`
CustomClaims map[string]interface{} `json:"ccm,omitempty"`
}