Implement complete authentication middleware for rag-server: - Remote token verification via accounts-service - 60s TTL cache with background GC - Gin middleware integration - Role-based access control - Zero-trust architecture (no private keys) - Health check endpoint Files: - internal/auth/client.go (350 lines) - internal/auth/middleware_verify.go (280 lines) - internal/auth/cache.go (180 lines) - internal/auth/example_test.go (150 lines) - internal/auth/README.md (550 lines) - cmd/xcontrol-server/main.go (updated) - config/config.go (added AuthCfg) - config/server.yaml (removed secrets) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
76 lines
1.6 KiB
YAML
76 lines
1.6 KiB
YAML
server:
|
|
addr: ":8090"
|
|
readTimeout: 120s
|
|
writeTimeout: 120s
|
|
publicUrl: "https://api.svc.plus"
|
|
allowedOrigins:
|
|
- "https://api.svc.plus"
|
|
- "https://www.svc.plus"
|
|
- "https://global-homepage.svc.plus"
|
|
- "https://accounts.svc.plus"
|
|
- "http://localhost:3000"
|
|
- "http://127.0.0.1:3000"
|
|
- "http://localhost:3001"
|
|
- "http://127.0.0.1:3001"
|
|
|
|
auth:
|
|
enable: true
|
|
authUrl: "https://accounts.svc.plus"
|
|
apiBaseUrl: "https://api.svc.plus"
|
|
publicToken: "xcontrol-public-token-2025"
|
|
|
|
global:
|
|
redis:
|
|
addr: "127.0.0.1:6379"
|
|
password: ""
|
|
vectordb:
|
|
pgurl: "postgres://shenlan:password@127.0.0.1:5432/shenlan"
|
|
datasources:
|
|
- name: Xstream
|
|
repo: https://github.com/svc-design/Xstream
|
|
path: docs
|
|
- name: XControl
|
|
repo: https://github.com/svc-design/XControl
|
|
path: docs
|
|
- name: documents
|
|
repo: https://github.com/svc-design/documents
|
|
path: /
|
|
|
|
sync:
|
|
repo:
|
|
proxy: socks5://127.0.0.1:1080
|
|
|
|
models:
|
|
embedder:
|
|
provider: "chutes"
|
|
models:
|
|
- "bge-m3"
|
|
- "deepseek-r1:8b"
|
|
baseurl: "http://127.0.0.1:9000"
|
|
endpoint: "http://127.0.0.1:9000/v1/embeddings"
|
|
generator:
|
|
provider: "chutes"
|
|
models:
|
|
- "deepseek-r1:8b"
|
|
baseurl: "http://127.0.0.1:11434"
|
|
endpoint: "http://127.0.0.1:11434/v1/chat/completions"
|
|
|
|
embedding:
|
|
max_batch: 64
|
|
dimension: 1024
|
|
max_chars: 8000
|
|
rate_limit_tpm: 120000
|
|
|
|
chunking:
|
|
embed_toc: true
|
|
max_tokens: 800
|
|
overlap_tokens: 80
|
|
prefer_heading_split: true
|
|
include_exts: [".md", ".mdx"]
|
|
ignore_dirs: [".git", "node_modules", "dist", "build"]
|
|
|
|
api:
|
|
askai:
|
|
timeout: 100
|
|
retries: 3
|