feat: implement single binary build and env-based auth
- Unify login page styling with share page - Add AGENTS.md with build commands and code style guidelines - Add dev.sh and make.sh for development and production builds - Implement single binary build with embedded frontend using embed.FS - Change auth configuration from CLI flag to env variables (USHARE_USERNAME, USHARE_PASSWORD) - Set default credentials: admin / ushare@123 - Fix static file serving for SPA routes
This commit is contained in:
@@ -4,13 +4,15 @@ import (
|
||||
"context"
|
||||
"github.com/loveuer/nf/nft/log"
|
||||
"github.com/loveuer/ushare/internal/pkg/tool"
|
||||
"os"
|
||||
)
|
||||
|
||||
type config struct {
|
||||
Debug bool
|
||||
Address string
|
||||
DataPath string
|
||||
Auth string
|
||||
Username string
|
||||
Password string
|
||||
CleanInterval int
|
||||
}
|
||||
|
||||
@@ -19,8 +21,22 @@ var (
|
||||
)
|
||||
|
||||
func Init(_ context.Context) {
|
||||
if Cfg.Auth != "" {
|
||||
Cfg.Auth = tool.NewPassword(Cfg.Auth)
|
||||
log.Debug("opt.Init: encrypted password = %s", Cfg.Auth)
|
||||
if Cfg.Username == "" {
|
||||
Cfg.Username = "admin"
|
||||
}
|
||||
if Cfg.Password == "" {
|
||||
Cfg.Password = "ushare@123"
|
||||
}
|
||||
|
||||
Cfg.Password = tool.NewPassword(Cfg.Password)
|
||||
log.Debug("opt.Init: username = %s, encrypted password = %s", Cfg.Username, Cfg.Password)
|
||||
}
|
||||
|
||||
func LoadFromEnv() {
|
||||
if username := os.Getenv("USHARE_USERNAME"); username != "" {
|
||||
Cfg.Username = username
|
||||
}
|
||||
if password := os.Getenv("USHARE_PASSWORD"); password != "" {
|
||||
Cfg.Password = password
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user