Skip to content

Commit

Permalink
Fix: oci auth
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalholthaus authored and greenbonebot committed Apr 23, 2024
1 parent 1b68f7a commit 5e6ec44
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions oci-info/action/oci.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,10 @@ def __init__(
super().__init__(
base_url=f"https://{reg_domain}",
timeout=timeout,
auth=(user, password) if user else None,
headers={"accept": ",".join([h.value for h in OciMediaTypes])},
)

self.user_auth = (user, password) if user else None
self.reg_domain = reg_domain
self.reg_auth_domain = reg_auth_domain
self.reg_auth_service = reg_auth_service
Expand All @@ -90,7 +91,8 @@ def _get_data_as_dict(self, url: str) -> dict[str, Any]:
def _set_auth_token(self, repository) -> None:
res = self.get(
f"https://{self.reg_auth_domain}/token?service={self.reg_auth_service}"
f"&scope=repository:{self.namespace}/{repository}:pull"
f"&scope=repository:{self.namespace}/{repository}:pull",
auth=self.user_auth, # type: ignore
)
res.raise_for_status()
self.headers["authorization"] = f"Bearer {res.json()['token']}"
Expand Down Expand Up @@ -158,7 +160,7 @@ def get_oci_annotations(
and manifest.platform.architecture == architecture
):
try:
return OciAnnotations(**manifest.annotations)
return OciAnnotations(**manifest.annotations) # type: ignore
except ValidationError as exc:
raise OciAnnotationsError(
f"Failed to get OCI annotations from repository {repository} on tag {tag}."
Expand Down

0 comments on commit 5e6ec44

Please sign in to comment.