fix: remove tenant dependency from member login

This commit is contained in:
richjohnrambo
2026-10-19 01:03:31 +08:00
parent 804318e5f5
commit 2e47dd3935
13 changed files with 51 additions and 38 deletions
-14
View File
@@ -67,7 +67,6 @@ type AuthConfig struct {
APIKeys []string `json:"api_keys"`
SessionKeyPattern string `json:"session_key_pattern"`
SessionTTLSeconds int `json:"session_ttl_seconds"`
DefaultTenantID int64 `json:"default_tenant_id"`
DataEncryptionKey string `json:"data_encryption_key"`
LookupHMACKey string `json:"lookup_hmac_key"`
FinanceMasterKey string `json:"finance_master_key"`
@@ -106,7 +105,6 @@ func defaultConfig() *Config {
Auth: AuthConfig{
SessionKeyPattern: "olons_server:session:token:%s",
SessionTTLSeconds: 14 * 24 * 60 * 60,
DefaultTenantID: 0,
RequiredAPIKey: true,
},
Upload: UploadConfig{Driver: "local", Dir: "storage/uploads", PublicPath: "/uploads", Region: "us-east-1"},
@@ -133,7 +131,6 @@ func applyEnv(cfg *Config) {
setInt(&cfg.Redis.DB, "OLONS_SERVER_REDIS_DB")
setString(&cfg.Auth.SessionKeyPattern, "OLONS_SERVER_SESSION_KEY_PATTERN")
setInt(&cfg.Auth.SessionTTLSeconds, "OLONS_SERVER_SESSION_TTL_SECONDS")
setInt64(&cfg.Auth.DefaultTenantID, "OLONS_SERVER_DEFAULT_TENANT_ID")
setString(&cfg.Auth.DataEncryptionKey, "OLONS_SERVER_DATA_ENCRYPTION_KEY")
setString(&cfg.Auth.LookupHMACKey, "OLONS_SERVER_LOOKUP_HMAC_KEY")
setString(&cfg.Auth.FinanceMasterKey, "OLONS_SERVER_FINANCE_MASTER_KEY")
@@ -177,9 +174,6 @@ func (c *Config) validate() error {
if c.Auth.SessionTTLSeconds <= 0 {
c.Auth.SessionTTLSeconds = 14 * 24 * 60 * 60
}
if c.Auth.DefaultTenantID < 0 {
return errors.New("default tenant id must not be negative")
}
if err := ValidateUpload(c.Upload); err != nil {
return err
}
@@ -261,14 +255,6 @@ func setInt(target *int, key string) {
}
}
func setInt64(target *int64, key string) {
if value := strings.TrimSpace(os.Getenv(key)); value != "" {
if parsed, err := strconv.ParseInt(value, 10, 64); err == nil {
*target = parsed
}
}
}
func setBool(target *bool, key string) {
switch strings.ToLower(strings.TrimSpace(os.Getenv(key))) {
case "1", "true", "yes", "on":
-3
View File
@@ -7,9 +7,6 @@ func TestDefaultConfigUsesOlonsAdmin(t *testing.T) {
if err := cfg.validate(); err != nil {
t.Fatal(err)
}
if cfg.Auth.DefaultTenantID != 0 {
t.Fatalf("DefaultTenantID = %d", cfg.Auth.DefaultTenantID)
}
}
func TestConfigRejectsOtherDatabase(t *testing.T) {