241e3b5f2d
- Introduced a new `auditlog` package to handle audit logging for user actions, including creation, updates, deletions, and authentication events. - Enhanced existing services (customer, user) to log relevant actions using the new audit logger, capturing details such as actor ID, action type, target type, and success status. - Added middleware to enrich request context with metadata for audit logging, ensuring comprehensive tracking of user interactions. - Integrated Elasticsearch for persistent storage of audit logs, with fallback to file-only logging if Elasticsearch is unavailable. - Updated API documentation to include new audit log endpoints for administrative access. This update significantly improves the system's ability to track and audit user actions, enhancing security and accountability within the application.
93 lines
3.9 KiB
Go
93 lines
3.9 KiB
Go
package bootstrap
|
|
|
|
import (
|
|
"time"
|
|
"tm/pkg/config"
|
|
)
|
|
|
|
// Config holds configuration for the web command
|
|
type Config struct {
|
|
Server config.ServerConfig
|
|
Database config.DatabaseConfig
|
|
Cache config.CacheConfig
|
|
Logging config.LoggingConfig
|
|
RateLimit config.RateLimitConfig
|
|
Assets config.AssetsConfig
|
|
Notification config.NotificationConfig
|
|
Ollama config.OllamaConfig
|
|
HCaptcha config.HCaptchaConfig
|
|
Scraper ScraperConfig
|
|
TED TEDConfig
|
|
UserAuth AuthConfig
|
|
CustomerAuth AuthConfig
|
|
DocumentScraper DocumentScraperConfig
|
|
AISummarizer AISummarizerConfig
|
|
GoRules GoRulesConfig
|
|
Elasticsearch config.ElasticsearchConfig
|
|
}
|
|
|
|
type ScraperConfig struct {
|
|
BaseURL string `env:"SCRAPER_BASE_URL"`
|
|
Timeout time.Duration `env:"SCRAPER_TIMEOUT"`
|
|
}
|
|
|
|
// TEDConfig holds configuration for TED scraper (one-time scraping from admin panel)
|
|
type TEDConfig struct {
|
|
BaseURL string `env:"TED_BASE_URL" envDefault:"https://ted.europa.eu"`
|
|
Timeout time.Duration `env:"TED_TIMEOUT" envDefault:"30s"`
|
|
MaxRetries int `env:"TED_MAX_RETRIES" envDefault:"3"`
|
|
RetryDelay time.Duration `env:"TED_RETRY_DELAY" envDefault:"5s"`
|
|
UserAgent string `env:"TED_USER_AGENT" envDefault:"TM-TED-Scraper/1.0"`
|
|
MaxConcurrency int `env:"TED_MAX_CONCURRENCY" envDefault:"5"`
|
|
DownloadDir string `env:"TED_DOWNLOAD_DIR" envDefault:"./downloads"`
|
|
CleanupAfter time.Duration `env:"TED_CLEANUP_AFTER" envDefault:"24h"`
|
|
ScrapingInterval string `env:"TED_SCRAPING_INTERVAL" envDefault:"* * 10 * * *"`
|
|
MaxNoticesPerDay int `env:"TED_MAX_NOTICES_PER_DAY" envDefault:"0"`
|
|
AlertMail string `env:"ALERT_MAIL" envDefault:"alerts@opplens.com"`
|
|
}
|
|
|
|
type AuthConfig struct {
|
|
JWT JWTConfig
|
|
}
|
|
|
|
type JWTConfig struct {
|
|
AccessSecret string `env:"USER_AUTH_ACCESS_SECRET"`
|
|
RefreshSecret string `env:"USER_AUTH_REFRESH_SECRET"`
|
|
AccessExpiresIn int `env:"USER_AUTH_ACCESS_EXPIRES_IN"`
|
|
RefreshExpiresIn int `env:"USER_AUTH_REFRESH_EXPIRES_IN"`
|
|
}
|
|
|
|
// DocumentScraperConfig holds configuration for the external document scraper service API
|
|
type DocumentScraperConfig struct {
|
|
APIKey string `env:"DOCUMENT_SCRAPER_API_KEY" envDefault:""`
|
|
}
|
|
|
|
// AISummarizerConfig holds configuration for the external AI summarizer service
|
|
type AISummarizerConfig struct {
|
|
// HTTP API settings
|
|
APIBaseURL string `env:"AI_SUMMARIZER_API_BASE_URL" envDefault:""`
|
|
APITimeout time.Duration `env:"AI_SUMMARIZER_API_TIMEOUT" envDefault:"120s"`
|
|
APIRetryCount int `env:"AI_SUMMARIZER_API_RETRY_COUNT" envDefault:"2"`
|
|
APIRetryDelay time.Duration `env:"AI_SUMMARIZER_API_RETRY_DELAY" envDefault:"3s"`
|
|
DefaultLanguage string `env:"AI_SUMMARIZER_DEFAULT_LANGUAGE" envDefault:"en"`
|
|
// RecommendationCacheTTL is an optional max Redis TTL for cached recommendations.
|
|
// When 0 (default), entries persist until the company is created, updated, or onboarded.
|
|
RecommendationCacheTTL time.Duration `env:"AI_RECOMMENDATION_CACHE_TTL" envDefault:"0"`
|
|
|
|
// MinIO storage settings
|
|
MinioEndpoint string `env:"AI_SUMMARIZER_MINIO_ENDPOINT" envDefault:""`
|
|
MinioAccessKey string `env:"AI_SUMMARIZER_MINIO_ACCESS_KEY" envDefault:""`
|
|
MinioSecretKey string `env:"AI_SUMMARIZER_MINIO_SECRET_KEY" envDefault:""`
|
|
MinioUseSSL bool `env:"AI_SUMMARIZER_MINIO_USE_SSL" envDefault:"false"`
|
|
MinioRegion string `env:"AI_SUMMARIZER_MINIO_REGION" envDefault:"us-east-1"`
|
|
MinioBucket string `env:"AI_SUMMARIZER_MINIO_BUCKET" envDefault:"opplens"`
|
|
}
|
|
|
|
// GoRulesConfig holds configuration for the GoRules status engine.
|
|
type GoRulesConfig struct {
|
|
BaseURL string `env:"GORULES_BASE_URL"`
|
|
Token string `env:"GORULES_TOKEN"`
|
|
RuleID string `env:"GORULES_RULE_ID"`
|
|
Timeout time.Duration `env:"GORULES_TIMEOUT"`
|
|
}
|