forked from Rockachopa/Timmy-time-dashboard
Merge pull request 'feat: Timmy authenticates to Gitea as himself' (#119) from feat/timmy-gitea-identity into main
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -81,3 +81,4 @@ workspace/
|
||||
.LSOverride
|
||||
.Spotlight-V100
|
||||
.Trashes
|
||||
.timmy_gitea_token
|
||||
|
||||
@@ -246,7 +246,7 @@ class Settings(BaseSettings):
|
||||
# Local Gitea instance for issue tracking and self-improvement.
|
||||
# These values are passed as env vars to the gitea-mcp server process.
|
||||
gitea_url: str = "http://localhost:3000"
|
||||
gitea_token: str = "" # GITEA_TOKEN env var; falls back to ~/.config/gitea/token
|
||||
gitea_token: str = "" # GITEA_TOKEN env var; falls back to .timmy_gitea_token
|
||||
gitea_repo: str = "rockachopa/Timmy-time-dashboard" # owner/repo
|
||||
gitea_enabled: bool = True
|
||||
|
||||
@@ -347,14 +347,19 @@ class Settings(BaseSettings):
|
||||
def model_post_init(self, __context) -> None:
|
||||
"""Post-init: resolve gitea_token from file if not set via env."""
|
||||
if not self.gitea_token:
|
||||
token_path = os.path.expanduser("~/.config/gitea/token")
|
||||
try:
|
||||
if os.path.isfile(token_path):
|
||||
token = open(token_path).read().strip() # noqa: SIM115
|
||||
if token:
|
||||
self.gitea_token = token
|
||||
except OSError:
|
||||
pass
|
||||
# Priority: Timmy's own token → legacy admin token
|
||||
repo_root = self._compute_repo_root()
|
||||
timmy_token_path = os.path.join(repo_root, ".timmy_gitea_token")
|
||||
legacy_token_path = os.path.expanduser("~/.config/gitea/token")
|
||||
for token_path in (timmy_token_path, legacy_token_path):
|
||||
try:
|
||||
if os.path.isfile(token_path):
|
||||
token = open(token_path).read().strip() # noqa: SIM115
|
||||
if token:
|
||||
self.gitea_token = token
|
||||
break
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
model_config = SettingsConfigDict(
|
||||
env_file=".env",
|
||||
|
||||
Reference in New Issue
Block a user