Closed AresEkb closed 9 months ago
I'd personally be concerned about having my PAT visible in the file system, but that's the user's choice. Better would be to find a way to prompt for credentials, store then in secure storage, and produce the appropriate request headers from that information...
An access token can be send in Authorization
or Private-Token
HTTP header:
curl --header 'Authorization: Bearer ACCESS_TOKEN' 'https://gitlab.eclipse.org/api/v4/projects/3814/repository/files/releng%2Forg.eclipse.ease.releng%2Foomph%2Fease.setup/raw'
curl --header 'Private-Token: ACCESS_TOKEN' 'https://gitlab.eclipse.org/api/v4/projects/3814/repository/files/releng%2Forg.eclipse.ease.releng%2Foomph%2Fease.setup/raw'
Maybe support of bearer authorization can be added in addition to basic authorization?
Yes, that would be cool. That being said, we are using ECF under the covers and the header stuff is handled in that technology stack so not so trivial to enhance. Then there is also the problem of reproducibility. I don't have access to a gitlab instance with a private repo where I can really properly test what's working and what isn't. When I tried this stuff with gitlab.eclipse.org using a bogus/wrong token, it prompted me for credentials, though I did not try to enter any but rather created a proper token. And finally, there is the problem of time investment, i.e., not having time. 😱
It works fine for public repositories with anonymous access. For instance, a setup-file can be downloaded using such an URL https://gitlab.eclipse.org/eclipse/ease/ease/-/raw/main/releng/org.eclipse.ease.releng/oomph/ease.setup
But it doesn't work for private GitLab repositories.
It seems that GitLab doesn't support basic authentication. Here is an open issue. And also basic authentication is not mentioned in the documentation.
So the following URL will not work: https://gitlab.eclipse.org/eclipse/ease/ease/-/raw/main/releng/org.eclipse.ease.releng/oomph/ease.setup?oomph_basic_auth=true
GitLab will redirect to an HTML login form.
It's possible to clone a Git repository using ACCESS_TOKEN:
But it seems that it's impossible to use such an URL to download a specific file.
Probably the only way to download a file from a private GitLab repository is to use Files API. In that case the followin URL should be used (you can ommit ACCESS_TOKEN if a repository allows anonymous access): https://gitlab.eclipse.org/api/v4/projects/3814/repository/files/releng%2Forg.eclipse.ease.releng%2Foomph%2Fease.setup/raw?private_token=ACCESS_TOKEN
It works fine. But Eclipse Installer throws the following exception:
I guess the cause is a wrong file name - raw (because the last segment of URL is raw). The file doesn't have setup extension.
It also seems that not all versions of GitLab returns correct HTTP headers:
Content-Disposition
header should contain a valid file name.Probably one of the ways to fix the problem is to register a Setup Resource Factory as a fallback one.
A discussion is available here.