Skip to content

Commit 41d886a

Browse files
committed
Vastly simplify the auth hooks interface
1 parent 89ef700 commit 41d886a

3 files changed

Lines changed: 6 additions & 22 deletions

File tree

pulp-glue/src/pulp_glue/common/authentication.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,10 @@ def can_complete(
4242
# This covers the case where `[]` allows for no auth at all.
4343
return True
4444

45-
async def auth_success_hook(
46-
self, proposal: dict[str, list[str]], security_schemes: dict[str, dict[str, t.Any]]
47-
) -> None:
45+
async def auth_success_hook(self, **kwargs: t.Any) -> None:
4846
pass
4947

50-
async def auth_failure_hook(
51-
self, proposal: dict[str, list[str]], security_schemes: dict[str, dict[str, t.Any]]
52-
) -> None:
48+
async def auth_failure_hook(self, **kwargs: t.Any) -> None:
5349
pass
5450

5551
async def http_basic_credentials(self) -> tuple[bytes, bytes]:

pulp-glue/src/pulp_glue/common/openapi.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -726,17 +726,9 @@ def call(
726726
response = self._send_request(request)
727727

728728
if response.status_code >= 200 and response.status_code < 300:
729-
asyncio.run(
730-
self._auth_provider.auth_success_hook(
731-
proposal, self.api_spec["components"]["securitySchemes"]
732-
)
733-
)
729+
asyncio.run(self._auth_provider.auth_success_hook())
734730
elif response.status_code == 401:
735-
asyncio.run(
736-
self._auth_provider.auth_failure_hook(
737-
proposal, self.api_spec["components"]["securitySchemes"]
738-
)
739-
)
731+
asyncio.run(self._auth_provider.auth_failure_hook())
740732

741733
self._log_response(response)
742734
return self._parse_response(method_spec, response)

src/pulp_cli/generic.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -281,9 +281,7 @@ def _save_password_to_storage(self) -> None:
281281
collection = secretstorage.get_default_collection(connection)
282282
collection.create_item("Pulp CLI", secret_attr, password, replace=True)
283283

284-
async def auth_success_hook(
285-
self, proposal: dict[str, list[str]], security_schemes: dict[str, dict[str, t.Any]]
286-
) -> None:
284+
async def auth_success_hook(self, **kwargs: t.Any) -> None:
287285
if SECRET_STORAGE and self._password_in_secretstorage is False:
288286
await asyncio.get_running_loop().run_in_executor(None, self._save_password_to_storage)
289287
self._password_in_secretstorage = None
@@ -305,9 +303,7 @@ def _remove_password_from_storage(self) -> None:
305303
item.delete()
306304
self.password = None
307305

308-
async def auth_failure_hook(
309-
self, proposal: dict[str, list[str]], security_schemes: dict[str, dict[str, t.Any]]
310-
) -> None:
306+
async def auth_failure_hook(self, **kwargs: t.Any) -> None:
311307
if SECRET_STORAGE and self._password_in_secretstorage is True:
312308
await asyncio.get_running_loop().run_in_executor(
313309
None, self._remove_password_from_storage

0 commit comments

Comments
 (0)