How to use a PyArtifactory client without auth? #173
Answered
by
anancarv
NiklasRosenstein
asked this question in
Q&A
-
How can I create a |
Beta Was this translation helpful? Give feedback.
Answered by
anancarv
Sep 20, 2024
Replies: 2 comments 1 reply
-
Hey @NiklasRosenstein, it is not possible to access an Artifactory instance anonymously using this library. You need to authenticate yourself using username/password. |
Beta Was this translation helpful? Give feedback.
0 replies
-
I was able to work around this with a bit of hackery: from typing import Tuple
from pyartifactory import Artifactory as _Artifactory
from pyartifactory.objects.object import ArtifactoryObject
from pydantic import SecretStr
class Artifactory(_Artifactory):
"""
Extends the Artifactory client to permit anonymous access.
"""
def __init__(
self,
url: str,
auth: Tuple[str, SecretStr | str] | None,
verify: bool | str = True,
cert: str | None = None,
api_version: int = 1,
):
if anonymous := auth is None:
auth = ("", SecretStr(""))
else:
user, password = auth
if not isinstance(password, SecretStr):
password = SecretStr(password)
auth = (user, password)
super().__init__(url, auth, verify, cert, api_version)
if anonymous:
for value in vars(self).values():
if isinstance(value, ArtifactoryObject):
value._auth = None # type: ignore[assignment] |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey @NiklasRosenstein, it is now possible to access Artifactory instances anonymously in v2.7.0