Orange-OpenSource / rtpy

Python wrapper for the JFrog Artifactory REST API
Apache License 2.0
15 stars 10 forks source link

Artifactory Identity token #4

Open ambua opened 1 year ago

ambua commented 1 year ago

Hi Developers, We need to use Artifactory Identity token instead of API Key: https://www.jfrog.com/confluence/display/JFROG/User+Profile#UserProfile-identitytoken

Technically the request on Artifactory should change like so: https://www.jfrog.com/confluence/display/JFROG/Access+Tokens#AccessTokens-AuthorizationHeaders

# Old: API key: 
 curl -H 'X-JFrog-Art-Api:$API_KEY' "https://some.artifactory.com/artifactory/my-repo/my_artifact.bin"
# New: Identity token:
 curl -H 'Authorization: Bearer $USER_TOKEN' "https://some.artifactory.com/artifactory/my-repo/my_artifact.bin"

I was able to monkey patch the _request method like so: https://github.com/Orange-OpenSource/rtpy/blob/master/rtpy/tools.py#L253

        if self._user_settings["X-JFrog-Art-Api"]:
            # Use Artifactory identity token instead of API key
            #headers = {"X-JFrog-Art-Api": self._user_settings["X-JFrog-Art-Api"]}
            headers = {"Authorization": f"Bearer {self._user_settings['X-JFrog-Art-Api']}"}

This is not very nice. So would you agree to add this feature? Or do you see another better way without code changes? I think it is not a big thing. I can also add a pull request if you like. Best regards, Adrian

guillaumerenault commented 1 year ago

Hi Adrian, I'm no longer maintaining the project as I don't work for the company that released it, you can however open a pull request to discuss and show your suggested changes. I can reach out to some of my former colleagues who could potentially publish a new release.

If you do open the PR, please run the tests to make sure everything is still working (make sure to run the tests only on a Artifactory test instance).

Hope that helps!

Guillaume