Add Redmine API token authentication
This commit is contained in:
@@ -1,9 +1,18 @@
|
||||
from typing import List, Optional, Dict, Tuple
|
||||
from typing import Any, Dict, List, Optional, Tuple
|
||||
from redminelib import Redmine
|
||||
from redminelib.resources import Issue
|
||||
from .config import Config
|
||||
from .utils import get_version
|
||||
|
||||
REQUESTS_OPTIONS = {"verify": "/etc/ssl/certs/ca-certificates.crt"}
|
||||
|
||||
|
||||
def _get_redmine_auth_kwargs() -> Dict[str, Any]:
|
||||
"""Return Redmine auth kwargs. API key has priority over legacy password auth."""
|
||||
if Config.REDMINE_API_KEY:
|
||||
return {"key": Config.REDMINE_API_KEY}
|
||||
return {"username": Config.REDMINE_USER, "password": Config.REDMINE_PASSWORD}
|
||||
|
||||
|
||||
def fetch_issues_with_spent_time(
|
||||
from_date: str, to_date: str
|
||||
@@ -16,9 +25,8 @@ def fetch_issues_with_spent_time(
|
||||
|
||||
redmine = Redmine(
|
||||
Config.REDMINE_URL,
|
||||
username=Config.REDMINE_USER,
|
||||
password=Config.REDMINE_PASSWORD,
|
||||
requests={"verify": "/etc/ssl/certs/ca-certificates.crt"},
|
||||
**_get_redmine_auth_kwargs(),
|
||||
requests=REQUESTS_OPTIONS,
|
||||
)
|
||||
|
||||
current_user = redmine.user.get("current")
|
||||
@@ -40,7 +48,9 @@ def fetch_issues_with_spent_time(
|
||||
|
||||
# Загружаем полные объекты задач
|
||||
issue_list_str = ",".join(str(i) for i in issue_ids)
|
||||
issues = redmine.issue.filter(issue_id=issue_list_str, status_id="*", sort="project:asc")
|
||||
issues = redmine.issue.filter(
|
||||
issue_id=issue_list_str, status_id="*", sort="project:asc"
|
||||
)
|
||||
|
||||
# Сопоставляем задачи с суммарным временем
|
||||
result = []
|
||||
|
||||
Reference in New Issue
Block a user