Skip to content

Commit 9284a8b

Browse files
committed
Use authorization header instead of X-JFrog-Art-Api
1 parent b1efab4 commit 9284a8b

File tree

4 files changed

+9
-5
lines changed

4 files changed

+9
-5
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ export ARTIFACTORY_TOKEN="my-token"
5858
./code-marketplace [command] --artifactory http://artifactory.server/artifactory --repo extensions
5959
```
6060

61+
The token will be used as the `Authorization` header with the value `Bearer
62+
<TOKEN>`.
63+
6164
### Exposing the marketplace
6265

6366
The marketplace must be put behind TLS otherwise code-server will reject

fixtures/upload.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
set -Eeuo pipefail
55

66
cd ./extensions
7-
find . -type f -exec curl -H "X-JFrog-Art-Api:$ARTIFACTORY_TOKEN" -T '{}' "$ARTIFACTORY_URI/$ARTIFACTORY_REPO/"'{}' \;
7+
find . -type f -exec curl -H "Authorization: Bearer $ARTIFACTORY_TOKEN" -T '{}' "$ARTIFACTORY_URI/$ARTIFACTORY_REPO/"'{}' \;

storage/artifactory.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ func (s *Artifactory) request(ctx context.Context, method, endpoint string, r io
138138
if err != nil {
139139
return nil, http.StatusInternalServerError, err
140140
}
141-
req.Header.Add("X-JFrog-Art-Api", s.token)
141+
req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", s.token))
142142
resp, err := http.DefaultClient.Do(req)
143143
if err != nil {
144144
return nil, http.StatusInternalServerError, err

storage/artifactory_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"bytes"
55
"context"
66
"errors"
7+
"fmt"
78
"io"
89
"net/http"
910
"net/http/httptest"
@@ -176,7 +177,7 @@ func artifactoryFactory(t *testing.T) testStorage {
176177
t.Log("Failed to clean up", err)
177178
return
178179
}
179-
req.Header.Add("X-JFrog-Art-Api", token)
180+
req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", token))
180181
res, err := http.DefaultClient.Do(req)
181182
if err != nil {
182183
t.Log("Failed to clean up", err)
@@ -192,15 +193,15 @@ func artifactoryFactory(t *testing.T) testStorage {
192193
write: func(content []byte, elem ...string) {
193194
req, err := http.NewRequest(http.MethodPut, uri+path.Join(repo, path.Join(elem...)), bytes.NewReader(content))
194195
require.NoError(t, err)
195-
req.Header.Add("X-JFrog-Art-Api", token)
196+
req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", token))
196197
res, err := http.DefaultClient.Do(req)
197198
require.NoError(t, err)
198199
defer res.Body.Close()
199200
},
200201
exists: func(elem ...string) bool {
201202
req, err := http.NewRequest(http.MethodGet, uri+path.Join(repo, path.Join(elem...)), nil)
202203
require.NoError(t, err)
203-
req.Header.Add("X-JFrog-Art-Api", token)
204+
req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", token))
204205
res, err := http.DefaultClient.Do(req)
205206
if err != nil {
206207
return false

0 commit comments

Comments
 (0)