Skip to content

Commit 4b3a109

Browse files
Add registry catalog scope for unauthenticated ACR
1 parent 8e4ac8c commit 4b3a109

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/code/ContainerRegistryServerAPICalls.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ internal class ContainerRegistryServerAPICalls : ServerApiCall
4646
const string containerRegistryFindImageVersionUrlTemplate = "https://{0}/v2/{1}/tags/list"; // 0 - registry, 1 - repo(modulename)
4747
const string containerRegistryStartUploadTemplate = "https://{0}/v2/{1}/blobs/uploads/"; // 0 - registry, 1 - packagename
4848
const string containerRegistryEndUploadTemplate = "https://{0}{1}&digest=sha256:{2}"; // 0 - registry, 1 - location, 2 - digest
49-
const string defaultScope = "repository:*:*";
49+
const string defaultScope = "&scope=repository:*:*&scope=registry:catalog:*";
5050
const string containerRegistryRepositoryListTemplate = "https://{0}/v2/_catalog"; // 0 - registry
5151

5252
#endregion
@@ -482,11 +482,11 @@ internal bool IsContainerRegistryUnauthenticated(string containerRegistyUrl, out
482482
return false;
483483
}
484484

485-
string content = "grant_type=access_token&service=" + service + "&scope=" + defaultScope;
485+
string content = "grant_type=access_token&service=" + service + defaultScope;
486486
var contentHeaders = new Collection<KeyValuePair<string, string>> { new KeyValuePair<string, string>("Content-Type", "application/x-www-form-urlencoded") };
487487

488488
// get the anonymous access token
489-
var url = $"{realm}?service={service}&scope={defaultScope}";
489+
var url = $"{realm}?service={service}{defaultScope}";
490490

491491
// we dont check the errorrecord here because we want to return false if we get a 401 and not throw an error
492492
var results = GetHttpResponseJObjectUsingContentHeaders(url, HttpMethod.Get, content, contentHeaders, out _);

0 commit comments

Comments
 (0)