57 lines
1.0 KiB
Go
57 lines
1.0 KiB
Go
package config
|
||
|
||
import (
|
||
"github.com/google/uuid"
|
||
"os"
|
||
"sync"
|
||
"time"
|
||
)
|
||
|
||
const (
|
||
ContextKeyUser = "user"
|
||
ContextKeySession = "session_data"
|
||
)
|
||
|
||
var (
|
||
Local = "storage"
|
||
LogsDirectory string
|
||
DirData string
|
||
HomeDir, _ = os.UserHomeDir()
|
||
TLSCertFile = HomeDir + "/GoProjects/certs/certbundle.pem"
|
||
TLSKeyFile = HomeDir + "/GoProjects/certs/server.key"
|
||
Storage AuthStorage
|
||
|
||
JwtSecretKey = []byte(uuid.NewString())
|
||
SessionStore sync.Map
|
||
SessionFile = "sessions.json"
|
||
)
|
||
|
||
type (
|
||
AuthStorage struct {
|
||
Users map[string]User
|
||
}
|
||
|
||
User struct {
|
||
Email string
|
||
Name string
|
||
Password string
|
||
}
|
||
)
|
||
|
||
// ///////////////// в handlers?
|
||
// Работа с файлом (дополнительная опция)
|
||
type (
|
||
FileSession struct {
|
||
ID string `json:"id"`
|
||
Data *SessionData `json:"data"`
|
||
}
|
||
|
||
SessionData struct {
|
||
Proto string `json:"proto"`
|
||
FileName string `json:"file_name"`
|
||
IP string `json:"ip"`
|
||
Token string `json:"token"`
|
||
LastCheck time.Time `json:"last_check"`
|
||
}
|
||
)
|