fix: move DEMO_USER_API_KEY from hardcoded to env var, add .env.example

This commit is contained in:
Accusys
2026-05-15 13:14:59 +08:00
parent 8a7ffc94e4
commit 9fef5fb70d
2 changed files with 28 additions and 64 deletions

View File

@@ -1,70 +1,31 @@
# Momentry Core Configuration Template # Momentry Core Environment Configuration
# Copy this file to .env and customize for your environment # Copy this file to .env and fill in your values
# DO NOT commit .env with real credentials to version control # DO NOT commit .env to version control
# =========================================== # Database
# Database Configuration DATABASE_URL=postgres://accusys@localhost:5432/momentry
# ===========================================
DATABASE_URL=postgres://user:password@localhost:5432/momentry
# =========================================== # Redis
# Redis Configuration REDIS_URL=redis://:accusys@localhost:6379
# ===========================================
REDIS_URL=redis://user:password@localhost:6379
REDIS_PASSWORD=your_redis_password
# =========================================== # API Keys
# MongoDB Configuration MOMENTRY_API_KEY=muser_your_demo_key_here
# =========================================== MOMENTRY_DEMO_API_KEY=muser_your_demo_key_here
MONGODB_URL=mongodb://user:password@localhost:27017/admin
MONGODB_DATABASE=momentry
# =========================================== # TMDB (optional, for movie metadata)
# Qdrant Configuration TMDB_API_KEY=your_tmdb_api_key_here
# ===========================================
QDRANT_URL=http://localhost:6333
QDRANT_API_KEY=your_qdrant_api_key
QDRANT_COLLECTION=momentry_v2_full
# =========================================== # Service URLs
# API Server Configuration MOMENTRY_FFMPEG=/opt/homebrew/opt/ffmpeg-full/bin/ffmpeg
# =========================================== MOMENTRY_LLM_SUMMARY_URL=http://127.0.0.1:8082/v1/chat/completions
API_HOST=127.0.0.1
API_PORT=3000
# =========================================== # Directories
# Directory Paths MOMENTRY_OUTPUT_DIR=/Users/accusys/momentry/output_dev
# =========================================== MOMENTRY_SCRIPTS_DIR=/Users/accusys/momentry_core_0.1/scripts
MOMENTRY_OUTPUT_DIR=/path/to/output
MOMENTRY_BACKUP_DIR=/path/to/backup
MOMENTRY_SCRIPTS_DIR=/path/to/momentry_core/scripts
MOMENTRY_PYTHON_PATH=/opt/homebrew/bin/python3.11 MOMENTRY_PYTHON_PATH=/opt/homebrew/bin/python3.11
# =========================================== # Encryption (32 bytes hex)
# Processor Timeouts (seconds) AUDIT_ENCRYPTION_KEY=
# ===========================================
MOMENTRY_ASR_TIMEOUT=3600
MOMENTRY_CUT_TIMEOUT=3600
MOMENTRY_DEFAULT_TIMEOUT=7200
# =========================================== # Schema (dev for playground, public for production)
# Watch Directories (comma separated) DATABASE_SCHEMA=dev
# ===========================================
WATCH_DIRECTORIES=~/Videos,~/Downloads
# ===========================================
# Logging
# ===========================================
RUST_LOG=info
# Options: trace, debug, info, warn, error
# ===========================================
# Ollama (for LLM integration)
# ===========================================
OLLAMA_HOST=http://localhost:11434
# ===========================================
# Model Paths
# ===========================================
# EMBEDDING_MODEL_PATH=./models/embedding
# LLM_MODEL_PATH=./models/llm

View File

@@ -5,7 +5,7 @@ use axum::{
routing::{delete, get, post}, routing::{delete, get, post},
Router, Router,
}; };
use once_cell::sync::OnceCell; use once_cell::sync::{Lazy, OnceCell};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::collections::HashMap; use std::collections::HashMap;
use sha2::{Digest, Sha256}; use sha2::{Digest, Sha256};
@@ -33,7 +33,10 @@ use super::universal_search::universal_search_routes;
use super::visual_chunk_search; use super::visual_chunk_search;
use crate::core::chunk::types::Chunk; use crate::core::chunk::types::Chunk;
static DEMO_USER_API_KEY: &str = "muser_68600856036340bcafc01930eb4bd839_1774418104_97221b69"; static DEMO_USER_API_KEY: Lazy<String> = Lazy::new(|| {
std::env::var("MOMENTRY_DEMO_API_KEY")
.unwrap_or_else(|_| "muser_68600856036340bcafc01930eb4bd839_1774418104_97221b69".to_string())
});
fn hash_password(password: &str) -> String { fn hash_password(password: &str) -> String {
let mut hasher = Sha256::new(); let mut hasher = Sha256::new();
@@ -601,7 +604,7 @@ async fn login(Json(req): Json<LoginRequest>) -> Json<LoginResponse> {
Json(LoginResponse { Json(LoginResponse {
success: true, success: true,
message: Some("Login successful".to_string()), message: Some("Login successful".to_string()),
api_key: Some(DEMO_USER_API_KEY.to_string()), api_key: Some(DEMO_USER_API_KEY.clone()),
user: Some(UserInfo { user: Some(UserInfo {
username: "demo".to_string(), username: "demo".to_string(),
}), }),