jiradc-cli 0.4.0__tar.gz → 0.5.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: jiradc-cli
3
- Version: 0.4.0
3
+ Version: 0.5.0
4
4
  Summary: Typer CLI for Jira Data Center using browser session cookies.
5
5
  Project-URL: Homepage, https://github.com/marcosgalleterobbva/jiradc-cli
6
6
  Project-URL: Repository, https://github.com/marcosgalleterobbva/jiradc-cli
@@ -2,4 +2,4 @@
2
2
 
3
3
  __all__ = ["__version__"]
4
4
 
5
- __version__ = "0.4.0"
5
+ __version__ = "0.5.0"
@@ -30,6 +30,7 @@ class JiraClient:
30
30
  def __init__(self, config: JiraConfig, timeout_seconds: int = 30) -> None:
31
31
  self.base_url = config.base_url.rstrip("/")
32
32
  self.timeout_seconds = timeout_seconds
33
+ self.xsrf_token = _extract_xsrf_token(config.cookie)
33
34
  self.session = requests.Session()
34
35
  self.session.headers.update(
35
36
  {
@@ -60,7 +61,14 @@ class JiraClient:
60
61
  request_headers = dict(self.session.headers)
61
62
  if method_upper in {"POST", "PUT", "PATCH", "DELETE"}:
62
63
  # Jira Data Center instances behind SSO/WAF frequently enforce XSRF checks on mutations.
63
- request_headers.setdefault("X-Atlassian-Token", "no-check")
64
+ if self.xsrf_token:
65
+ request_headers["X-Atlassian-Token"] = self.xsrf_token
66
+ else:
67
+ request_headers.setdefault("X-Atlassian-Token", "no-check")
68
+ request_headers.setdefault("Origin", self.base_url)
69
+ request_headers.setdefault(
70
+ "Referer", f"{self.base_url}/secure/Dashboard.jspa"
71
+ )
64
72
  if headers:
65
73
  request_headers.update(headers)
66
74
  try:
@@ -111,6 +119,14 @@ def _looks_like_html(text: str) -> bool:
111
119
  return lowered.startswith("<!doctype html") or lowered.startswith("<html")
112
120
 
113
121
 
122
+ def _extract_xsrf_token(cookie: str) -> str | None:
123
+ for part in cookie.split(";"):
124
+ chunk = part.strip()
125
+ if chunk.lower().startswith("atlassian.xsrf.token="):
126
+ return chunk.split("=", 1)[1].strip() or None
127
+ return None
128
+
129
+
114
130
  def _summarize_html_error(text: str, status_code: int) -> str:
115
131
  referral_match = re.search(r"log-referral-id\">([^<]+)<", text, re.IGNORECASE)
116
132
  referral = referral_match.group(1).strip() if referral_match else None
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: jiradc-cli
3
- Version: 0.4.0
3
+ Version: 0.5.0
4
4
  Summary: Typer CLI for Jira Data Center using browser session cookies.
5
5
  Project-URL: Homepage, https://github.com/marcosgalleterobbva/jiradc-cli
6
6
  Project-URL: Repository, https://github.com/marcosgalleterobbva/jiradc-cli
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "jiradc-cli"
7
- version = "0.4.0"
7
+ version = "0.5.0"
8
8
  description = "Typer CLI for Jira Data Center using browser session cookies."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -45,7 +45,7 @@ jiradc = "jiradc_cli.main:main"
45
45
  include = ["jiradc_cli*"]
46
46
 
47
47
  [tool.bumpversion]
48
- current_version = "0.4.0"
48
+ current_version = "0.5.0"
49
49
  parse = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)"
50
50
  serialize = ["{major}.{minor}.{patch}"]
51
51
  search = "{current_version}"
File without changes
File without changes