mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-20 13:31:56 +00:00
fix: adjust from boilerplate to lti project
This commit is contained in:
Vendored
BIN
Binary file not shown.
@@ -1,42 +0,0 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"os"
|
||||
"time"
|
||||
)
|
||||
|
||||
type AuthCfg struct {
|
||||
Issuer string
|
||||
JWTSecret string
|
||||
AccessTTL time.Duration
|
||||
RefreshTTL time.Duration
|
||||
RefreshCookieName string
|
||||
RefreshCookiePath string
|
||||
}
|
||||
|
||||
func LoadAuth() AuthCfg {
|
||||
return AuthCfg{
|
||||
JWTSecret: getenv("JWT_SECRET", "dev-secret-change-me"),
|
||||
AccessTTL: getenvDuration("ACCESS_TTL", 10*time.Minute),
|
||||
RefreshTTL: getenvDuration("REFRESH_TTL", 30*24*time.Hour),
|
||||
RefreshCookieName: getenv("REFRESH_COOKIE_NAME", "rt"),
|
||||
RefreshCookiePath: getenv("REFRESH_COOKIE_PATH", "/api/auth"),
|
||||
Issuer: getenv("ISSUER", "http://localhost:8080"),
|
||||
}
|
||||
}
|
||||
|
||||
func getenv(k, def string) string {
|
||||
if v := os.Getenv(k); v != "" {
|
||||
return v
|
||||
}
|
||||
return def
|
||||
}
|
||||
func getenvDuration(k string, def time.Duration) time.Duration {
|
||||
if v := os.Getenv(k); v != "" {
|
||||
d, err := time.ParseDuration(v)
|
||||
if err == nil {
|
||||
return d
|
||||
}
|
||||
}
|
||||
return def
|
||||
}
|
||||
@@ -3,7 +3,7 @@ package config
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/hafizhproject45/Golang-Boilerplate.git/internal/utils"
|
||||
"gitlab.com/mbugroup/lti-api.git/internal/utils"
|
||||
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"github.com/hafizhproject45/Golang-Boilerplate.git/internal/utils"
|
||||
"gitlab.com/mbugroup/lti-api.git/internal/utils"
|
||||
|
||||
"github.com/bytedance/sonic"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
|
||||
Reference in New Issue
Block a user