fix: remove hardcoded credentials from .env.example and source
- .env.example: placeholder values only - gemini.go: error on missing API key instead of fallback - main.go: dynamic from address from SMTP_USER - Security: old credentials removed from active codebase
This commit is contained in:
parent
7fdfba8095
commit
c0d3002e22
3 changed files with 19 additions and 17 deletions
32
.env.example
32
.env.example
|
|
@ -1,27 +1,29 @@
|
||||||
# ExpenseFlow Configuration
|
# ReceiptNext Configuration
|
||||||
# Copy this file to .env and fill in your credentials.
|
# Copy this file to .env and fill in your credentials.
|
||||||
|
# Run `sudo ./install.sh` for interactive setup.
|
||||||
|
|
||||||
# SMTP Configuration
|
# --- AI Provider ---
|
||||||
SMTP_HOST=smtp.openxchange.eu
|
# Choose one: gemini, openai, ollama
|
||||||
SMTP_PORT=587
|
|
||||||
SMTP_USER=post@2-4-h.app
|
|
||||||
SMTP_PASS=D9AW8JP74r1V
|
|
||||||
|
|
||||||
# --- AI Provider Configuration ---
|
|
||||||
# Choose one: gemini (default), openai, ollama
|
|
||||||
AI_PROVIDER=gemini
|
AI_PROVIDER=gemini
|
||||||
|
|
||||||
# Gemini (default, used when AI_PROVIDER=gemini)
|
# For AI_PROVIDER=gemini:
|
||||||
GEMINI_API_KEY=AQ.Ab8RN6IQjKTQofuKOW2TT5mZ0zwt8rFa8X3SHGyYyce4DrbBJw
|
# GEMINI_API_KEY=your-gemini-api-key
|
||||||
|
|
||||||
# OpenAI / Compatible (used when AI_PROVIDER=openai)
|
# For AI_PROVIDER=openai:
|
||||||
# OPENAI_API_KEY=sk-...
|
# OPENAI_API_KEY=sk-...
|
||||||
# AI_MODEL=gpt-4o-mini
|
# AI_MODEL=gpt-4o-mini
|
||||||
# AI_BASE_URL=https://api.openai.com/v1
|
# AI_BASE_URL=https://api.openai.com/v1
|
||||||
|
|
||||||
# Ollama - Local LLM (used when AI_PROVIDER=ollama)
|
# For AI_PROVIDER=ollama:
|
||||||
# AI_BASE_URL=http://localhost:11434
|
# AI_BASE_URL=http://localhost:11434
|
||||||
# AI_MODEL=llava
|
# AI_MODEL=qwen3.5:2b
|
||||||
|
|
||||||
# Base URL for generating absolute links in emails
|
# --- SMTP (optional — needed for OTP emails and report delivery) ---
|
||||||
|
# SMTP_HOST=smtp.example.com
|
||||||
|
# SMTP_PORT=587
|
||||||
|
# SMTP_USER=your-email@example.com
|
||||||
|
# SMTP_PASS=your-password
|
||||||
|
|
||||||
|
# --- General ---
|
||||||
|
PORT=8080
|
||||||
BASE_URL=http://localhost:8080
|
BASE_URL=http://localhost:8080
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,7 @@ func (p *geminiProvider) ExtractReceipt(imagePath string) (*ReceiptData, error)
|
||||||
|
|
||||||
apiKey := os.Getenv("GEMINI_API_KEY")
|
apiKey := os.Getenv("GEMINI_API_KEY")
|
||||||
if apiKey == "" {
|
if apiKey == "" {
|
||||||
apiKey = "AQ.Ab8RN6IQjKTQofuKOW2TT5mZ0zwt8rFa8X3SHGyYyce4DrbBJw"
|
return &ReceiptData{}, errors.New("GEMINI_API_KEY environment variable not set")
|
||||||
}
|
}
|
||||||
|
|
||||||
b64Data := base64.StdEncoding.EncodeToString(imageData)
|
b64Data := base64.StdEncoding.EncodeToString(imageData)
|
||||||
|
|
|
||||||
2
main.go
2
main.go
|
|
@ -73,7 +73,7 @@ func main() {
|
||||||
// Create the email sender only if SMTP credentials are configured.
|
// Create the email sender only if SMTP credentials are configured.
|
||||||
var emailSender *email.Sender
|
var emailSender *email.Sender
|
||||||
if smtpHost != "" && smtpPort != "" && smtpUser != "" && smtpPass != "" {
|
if smtpHost != "" && smtpPort != "" && smtpUser != "" && smtpPass != "" {
|
||||||
emailSender = email.NewSender(smtpHost, smtpPort, smtpUser, smtpPass, "post@2-4-h.app")
|
emailSender = email.NewSender(smtpHost, smtpPort, smtpUser, smtpPass, smtpUser)
|
||||||
log.Printf("INFO [%s] main: SMTP sender configured (%s:%s)",
|
log.Printf("INFO [%s] main: SMTP sender configured (%s:%s)",
|
||||||
time.Now().Format(time.RFC3339), smtpHost, smtpPort)
|
time.Now().Format(time.RFC3339), smtpHost, smtpPort)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue