Skip to content

Commit

Permalink
backend: allow using crt+key pair for Pulp authentication
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
FrostyX authored and nikromen committed Oct 29, 2024
1 parent 44fc8c3 commit f1ffc8b
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion backend/copr_backend/pulp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
"""
Expand Down

0 comments on commit f1ffc8b

Please sign in to comment.