cylera-cli 1.3.2__tar.gz → 1.3.3__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.
- {cylera_cli-1.3.2 → cylera_cli-1.3.3}/PKG-INFO +1 -1
- {cylera_cli-1.3.2 → cylera_cli-1.3.3}/cylera.py +2 -1
- {cylera_cli-1.3.2 → cylera_cli-1.3.3}/cylera_auth.py +19 -5
- {cylera_cli-1.3.2 → cylera_cli-1.3.3}/cylera_cli.egg-info/PKG-INFO +1 -1
- {cylera_cli-1.3.2 → cylera_cli-1.3.3}/pyproject.toml +1 -1
- {cylera_cli-1.3.2 → cylera_cli-1.3.3}/LICENSE +0 -0
- {cylera_cli-1.3.2 → cylera_cli-1.3.3}/README.md +0 -0
- {cylera_cli-1.3.2 → cylera_cli-1.3.3}/cylera_cli.egg-info/SOURCES.txt +0 -0
- {cylera_cli-1.3.2 → cylera_cli-1.3.3}/cylera_cli.egg-info/dependency_links.txt +0 -0
- {cylera_cli-1.3.2 → cylera_cli-1.3.3}/cylera_cli.egg-info/entry_points.txt +0 -0
- {cylera_cli-1.3.2 → cylera_cli-1.3.3}/cylera_cli.egg-info/requires.txt +0 -0
- {cylera_cli-1.3.2 → cylera_cli-1.3.3}/cylera_cli.egg-info/top_level.txt +0 -0
- {cylera_cli-1.3.2 → cylera_cli-1.3.3}/setup.cfg +0 -0
|
@@ -287,7 +287,8 @@ def auth_login(
|
|
|
287
287
|
open_browser=not no_browser)
|
|
288
288
|
# Exchange before storing anything, so an account Cylera won't
|
|
289
289
|
# accept isn't left half signed in.
|
|
290
|
-
token = cylera_auth.exchange_token(
|
|
290
|
+
token = cylera_auth.exchange_token(
|
|
291
|
+
base_url, authentication["access_token"], authentication["user"]["email"], at_login=True)
|
|
291
292
|
except CyleraLoginError as e:
|
|
292
293
|
print(f"Error: {e}", file=sys.stderr)
|
|
293
294
|
raise typer.Exit(1)
|
|
@@ -134,8 +134,13 @@ def device_login(
|
|
|
134
134
|
raise CyleraLoginError("The sign-in code expired. Run 'cylera auth login' again.")
|
|
135
135
|
|
|
136
136
|
|
|
137
|
-
def exchange_token(base_url: str, workos_access_token: str) -> str:
|
|
138
|
-
"""Exchange a WorkOS access token for a Cylera token.
|
|
137
|
+
def exchange_token(base_url: str, workos_access_token: str, email: str, at_login: bool = False) -> str:
|
|
138
|
+
"""Exchange a WorkOS access token for a Cylera token.
|
|
139
|
+
|
|
140
|
+
email is the WorkOS account it was issued for, named if Cylera
|
|
141
|
+
refuses it. The exchange doesn't say why it refuses (no Cylera
|
|
142
|
+
account, not migrated yet, disabled), so the message doesn't guess.
|
|
143
|
+
"""
|
|
139
144
|
response = requests.post(
|
|
140
145
|
f"{_key(base_url)}/auth/token_exchange",
|
|
141
146
|
json={"token": workos_access_token},
|
|
@@ -145,9 +150,18 @@ def exchange_token(base_url: str, workos_access_token: str) -> str:
|
|
|
145
150
|
raise CyleraLoginError(
|
|
146
151
|
"This Cylera API doesn't support signing in through WorkOS yet.")
|
|
147
152
|
if response.status_code == 401:
|
|
153
|
+
if at_login:
|
|
154
|
+
raise CyleraLoginError(
|
|
155
|
+
f"Cylera didn't accept the WorkOS account you signed in with ({email}).\n"
|
|
156
|
+
"If that's the wrong account, sign out of WorkOS in your browser, or open\n"
|
|
157
|
+
"the link in a private window with --no-browser. If it's yours, sign in to\n"
|
|
158
|
+
"the Cylera Portal once to finish setting up your account, or ask your\n"
|
|
159
|
+
"Cylera administrator for access."
|
|
160
|
+
)
|
|
148
161
|
raise CyleraLoginError(
|
|
149
|
-
"Cylera
|
|
150
|
-
"
|
|
162
|
+
f"Cylera no longer accepts the WorkOS account you signed in with ({email}).\n"
|
|
163
|
+
"Ask your Cylera administrator for access, or run 'cylera auth login' to\n"
|
|
164
|
+
"sign in with another account."
|
|
151
165
|
)
|
|
152
166
|
response.raise_for_status()
|
|
153
167
|
return response.json()["token"]
|
|
@@ -185,4 +199,4 @@ def cylera_token(base_url: str) -> str:
|
|
|
185
199
|
raise CyleraLoginError(f"WorkOS refresh failed: {response.text}")
|
|
186
200
|
authentication = response.json()
|
|
187
201
|
_store_login(base_url, {**login, "refresh_token": authentication["refresh_token"]})
|
|
188
|
-
return exchange_token(base_url, authentication["access_token"])
|
|
202
|
+
return exchange_token(base_url, authentication["access_token"], login["email"])
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|