fix(calendar): TZID Europe/Berlin for timed events/tasks, resolve real resource href on delete/update, fix _report_tasks XML; sync deployed servers (owamail, openwearables, ghostfolio), docs and tests
This commit is contained in:
1 parent
7c01e7be53
commit
75185ef2ba
41 files changed
+8834
-324
No files matched your search
@@ -4,6 +4,12 @@ Supports OAuth 2.0 Authorization Code flow with PKCE (for claude.ai):
|
||||
1. GET /authorize → auto-approves if client_id+client_secret valid, redirects with code
|
||||
2. POST /token grant_type=authorization_code → exchanges code for access_token
|
||||
3. Bearer access_token on MCP requests
|
||||
|
||||
Zusaetzlich nicht-ablaufende Service-Tokens (service_tokens.json) fuer
|
||||
Maschinen-Clients (opencode, OpenClaw), die einen statischen Authorization-
|
||||
Bearer-Header setzen. Format: {"<token>": {"user": "stefan", "label": "opencode-polo"}}.
|
||||
Ein Service-Token wird in _resolve_access_token() vor den OAuth-Access-Tokens
|
||||
geprueft und laeuft nie ab; Widerruf durch Entfernen aus der Datei.
|
||||
"""
|
||||
|
||||
import json
|
||||
@@ -23,7 +29,7 @@ from starlette.middleware.base import BaseHTTPMiddleware
|
||||
BASE_DIR = os.path.dirname(__file__)
|
||||
TOKENS_FILE = os.path.join(BASE_DIR, "tokens.json")
|
||||
CONFIG_FILE = os.path.join(BASE_DIR, "config.json")
|
||||
VALID_USERS = ["stefan", "kati", "test"]
|
||||
VALID_USERS = ["stefan", "kati", "test", "nova"]
|
||||
|
||||
_config_cache = None
|
||||
|
||||
@@ -37,6 +43,7 @@ def load_config():
|
||||
_tokens_cache = None
|
||||
_current_user: contextvars.ContextVar[str | None] = contextvars.ContextVar("current_user", default=None)
|
||||
_TOKEN_STORE = os.path.join(BASE_DIR, ".active_tokens.json")
|
||||
_SERVICE_TOKENS_FILE = os.path.join(BASE_DIR, "service_tokens.json")
|
||||
_auth_codes: dict[str, dict] = {}
|
||||
|
||||
|
||||
@@ -53,6 +60,15 @@ def _save_access_tokens(tokens):
|
||||
json.dump(tokens, f)
|
||||
|
||||
|
||||
def _load_service_tokens():
|
||||
try:
|
||||
with open(_SERVICE_TOKENS_FILE) as f:
|
||||
data = json.load(f)
|
||||
except (FileNotFoundError, json.JSONDecodeError):
|
||||
return {}
|
||||
return data if isinstance(data, dict) else {}
|
||||
|
||||
|
||||
def _load_tokens():
|
||||
global _tokens_cache
|
||||
if _tokens_cache is None:
|
||||
@@ -81,6 +97,10 @@ def _resolve_client(client_id, client_secret):
|
||||
|
||||
|
||||
def _resolve_access_token(token):
|
||||
# Nicht-ablaufende Service-Tokens zuerst (konstanter Vergleich).
|
||||
for stored, info in _load_service_tokens().items():
|
||||
if secrets.compare_digest(stored, token):
|
||||
return info.get("user") if isinstance(info, dict) else info
|
||||
tokens = _load_access_tokens()
|
||||
info = tokens.get(token)
|
||||
if not info:
|
||||
|
||||
Reference in new issue
Block a user