diff --git a/internal/bootstrap/config.go b/internal/bootstrap/config.go index c3ef8464a78..930105ffbd2 100644 --- a/internal/bootstrap/config.go +++ b/internal/bootstrap/config.go @@ -1,7 +1,6 @@ package bootstrap import ( - "io/ioutil" "os" "path/filepath" @@ -25,7 +24,7 @@ func InitConfig() { log.Fatalf("failed to create default config file") } } else { - configBytes, err := ioutil.ReadFile(flags.Config) + configBytes, err := os.ReadFile(flags.Config) if err != nil { log.Fatalf("reading config file error: %+v", err) } diff --git a/internal/conf/config.go b/internal/conf/config.go index ede490a9b4c..932300ff8ea 100644 --- a/internal/conf/config.go +++ b/internal/conf/config.go @@ -32,32 +32,32 @@ type LogConfig struct { } type Config struct { - Force bool `json:"force" env:"FORCE"` - Address string `json:"address" env:"ADDR"` - Port int `json:"port" env:"PORT"` - SiteURL string `json:"site_url" env:"SITE_URL"` - Cdn string `json:"cdn" env:"CDN"` - JwtSecret string `json:"jwt_secret" env:"JWT_SECRET"` - Database Database `json:"database"` - Scheme Scheme `json:"scheme"` - TempDir string `json:"temp_dir" env:"TEMP_DIR"` - Log LogConfig `json:"log"` + Force bool `json:"force" env:"FORCE"` + Address string `json:"address" env:"ADDR"` + Port int `json:"port" env:"PORT"` + SiteURL string `json:"site_url" env:"SITE_URL"` + Cdn string `json:"cdn" env:"CDN"` + JwtSecret string `json:"jwt_secret" env:"JWT_SECRET"` + TokenExpiresIn int `json:"token_expires_in" env:"TOKEN_EXPIRES_IN"` + Database Database `json:"database"` + Scheme Scheme `json:"scheme"` + TempDir string `json:"temp_dir" env:"TEMP_DIR"` + Log LogConfig `json:"log"` } func DefaultConfig() *Config { return &Config{ - Address: "0.0.0.0", - Port: 5244, - JwtSecret: random.String(16), - Cdn: "", - TempDir: "data/temp", + Address: "0.0.0.0", + Port: 5244, + JwtSecret: random.String(16), + TokenExpiresIn: 48, + TempDir: "data/temp", Database: Database{ Type: "sqlite3", Port: 0, TablePrefix: "x_", DBFile: "data/data.db", }, - // CaCheExpiration: 30, Log: LogConfig{ Enable: true, Name: "log/log.log", diff --git a/server/common/auth.go b/server/common/auth.go index 4fd842298cc..5ddf29c97ed 100644 --- a/server/common/auth.go +++ b/server/common/auth.go @@ -18,7 +18,7 @@ func GenerateToken(username string) (tokenString string, err error) { claim := UserClaims{ Username: username, RegisteredClaims: jwt.RegisteredClaims{ - ExpiresAt: jwt.NewNumericDate(time.Now().Add(12 * time.Hour)), + ExpiresAt: jwt.NewNumericDate(time.Now().Add(48 * time.Hour)), IssuedAt: jwt.NewNumericDate(time.Now()), NotBefore: jwt.NewNumericDate(time.Now()), }}