From bf84784f6eef9a087e0ccd0675117de74cee082e Mon Sep 17 00:00:00 2001 From: Jakub Kadlcik Date: Fri, 25 Oct 2024 17:03:36 +0200 Subject: [PATCH] backend: allow using crt+key pair for Pulp authentication See #3450 This will be necessary for the production Pulp instance. But we still want to keep the possibility of username+password auth for our local development. --- backend/copr_backend/pulp.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/backend/copr_backend/pulp.py b/backend/copr_backend/pulp.py index 3a93a1765..6937abcb0 100644 --- a/backend/copr_backend/pulp.py +++ b/backend/copr_backend/pulp.py @@ -50,6 +50,14 @@ def auth(self): """ return (self.config["username"], self.config["password"]) + @property + def cert(self): + """ + See Client Side Certificates + https://docs.python-requests.org/en/latest/user/advanced/ + """ + return (self.config["cert"], self.config["key"]) + def url(self, endpoint): """ A fully qualified URL for a given API endpoint @@ -74,7 +82,12 @@ def request_params(self): """ Default parameters for our requests """ - return {"auth": self.auth, "timeout": self.timeout} + params = {"timeout": self.timeout} + if all(self.cert): + params["cert"] = self.cert + else: + params["auth"] = self.auth + return params def create_repository(self, name): """