 131868bdca
			
		
	
	131868bdca
	
	
	
		
			
			Major security, observability, and configuration improvements:
## Security Hardening
- Implemented configurable CORS (no more wildcards)
- Added comprehensive auth middleware for admin endpoints
- Enhanced webhook HMAC validation
- Added input validation and rate limiting
- Security headers and CSP policies
## Configuration Management
- Made N8N webhook URL configurable (WHOOSH_N8N_BASE_URL)
- Replaced all hardcoded endpoints with environment variables
- Added feature flags for LLM vs heuristic composition
- Gitea fetch hardening with EAGER_FILTER and FULL_RESCAN options
## API Completeness
- Implemented GetCouncilComposition function
- Added GET /api/v1/councils/{id} endpoint
- Council artifacts API (POST/GET /api/v1/councils/{id}/artifacts)
- /admin/health/details endpoint with component status
- Database lookup for repository URLs (no hardcoded fallbacks)
## Observability & Performance
- Added OpenTelemetry distributed tracing with goal/pulse correlation
- Performance optimization database indexes
- Comprehensive health monitoring
- Enhanced logging and error handling
## Infrastructure
- Production-ready P2P discovery (replaces mock implementation)
- Removed unused Redis configuration
- Enhanced Docker Swarm integration
- Added migration files for performance indexes
## Code Quality
- Comprehensive input validation
- Graceful error handling and failsafe fallbacks
- Backwards compatibility maintained
- Following security best practices
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
		
	
		
			
				
	
	
		
			60 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			60 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
| package middleware
 | |
| 
 | |
| // Ported from Goji's middleware, source:
 | |
| // https://github.com/zenazn/goji/tree/master/web/middleware
 | |
| 
 | |
| import (
 | |
| 	"net/http"
 | |
| 	"time"
 | |
| )
 | |
| 
 | |
| // Unix epoch time
 | |
| var epoch = time.Unix(0, 0).UTC().Format(http.TimeFormat)
 | |
| 
 | |
| // Taken from https://github.com/mytrile/nocache
 | |
| var noCacheHeaders = map[string]string{
 | |
| 	"Expires":         epoch,
 | |
| 	"Cache-Control":   "no-cache, no-store, no-transform, must-revalidate, private, max-age=0",
 | |
| 	"Pragma":          "no-cache",
 | |
| 	"X-Accel-Expires": "0",
 | |
| }
 | |
| 
 | |
| var etagHeaders = []string{
 | |
| 	"ETag",
 | |
| 	"If-Modified-Since",
 | |
| 	"If-Match",
 | |
| 	"If-None-Match",
 | |
| 	"If-Range",
 | |
| 	"If-Unmodified-Since",
 | |
| }
 | |
| 
 | |
| // NoCache is a simple piece of middleware that sets a number of HTTP headers to prevent
 | |
| // a router (or subrouter) from being cached by an upstream proxy and/or client.
 | |
| //
 | |
| // As per http://wiki.nginx.org/HttpProxyModule - NoCache sets:
 | |
| //
 | |
| //	Expires: Thu, 01 Jan 1970 00:00:00 UTC
 | |
| //	Cache-Control: no-cache, private, max-age=0
 | |
| //	X-Accel-Expires: 0
 | |
| //	Pragma: no-cache (for HTTP/1.0 proxies/clients)
 | |
| func NoCache(h http.Handler) http.Handler {
 | |
| 	fn := func(w http.ResponseWriter, r *http.Request) {
 | |
| 
 | |
| 		// Delete any ETag headers that may have been set
 | |
| 		for _, v := range etagHeaders {
 | |
| 			if r.Header.Get(v) != "" {
 | |
| 				r.Header.Del(v)
 | |
| 			}
 | |
| 		}
 | |
| 
 | |
| 		// Set our NoCache headers
 | |
| 		for k, v := range noCacheHeaders {
 | |
| 			w.Header().Set(k, v)
 | |
| 		}
 | |
| 
 | |
| 		h.ServeHTTP(w, r)
 | |
| 	}
 | |
| 
 | |
| 	return http.HandlerFunc(fn)
 | |
| }
 |