Skip to content

Commit 1a3f41c

Browse files
Users/shrverm/fix dotnetcorecli push auth (#13191)
* fix dotnet nuget push onPrem by setting credential configuration (#13183) * Restrict credentials in config to Basic scheme (#13054) * bump task version of legacy tasks Co-authored-by: Jonathan Myers <[email protected]>
1 parent 9051c03 commit 1a3f41c

File tree

49 files changed

+143
-119
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+143
-119
lines changed

Tasks/Common/packaging-common/Strings/resources.resjson/en-US/resources.resjson

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"loc.messages.Info_SavingTempConfig": "Saving NuGet.config to a temporary config file.",
1313
"loc.messages.Info_UsingToolPath": "Using tool path: %s",
1414
"loc.messages.Info_UsingVersion": "Using version: %s",
15+
"loc.messages.Info_BasicCredRestriction": "This task now configures NuGet to send these credentials using the Basic scheme\nonly. Most users will be unaffected by this change. If these are Windows domain\ncredentials and they have recently stopped working, try setting the build\nvariable %s to the value '%s' (without quotes).",
1516
"loc.messages.NGCommon_AddingSources": "Setting credentials in NuGet.config",
1617
"loc.messages.NGCommon_AreaNotFoundInSps": "Unable to locate the '%s' [%s] area. The service containing that area may not be available in your region.",
1718
"loc.messages.NGCommon_DetectedNuGetExtensionsPath": "Detected NuGet extensions loader path (NUGET_EXTENSIONS_PATH environment variable): %s",

Tasks/Common/packaging-common/Tests/nugetL0.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ not xml
223223
helper.AddSourceToNuGetConfig("SourceCredentials", "http://credentials", "foo", "bar");
224224
assert.strictEqual(
225225
configFile,
226-
'<configuration><packageSources><add key="SourceName" value="http://source/"/><add key="SourceCredentials" value="http://credentials"/></packageSources><packageSourceCredentials><SourceCredentials><add key="Username" value="foo"/><add key="ClearTextPassword" value="bar"/></SourceCredentials></packageSourceCredentials></configuration>',
226+
'<configuration><packageSources><add key="SourceName" value="http://source/"/><add key="SourceCredentials" value="http://credentials"/></packageSources><packageSourceCredentials><SourceCredentials><add key="Username" value="foo"/><add key="ClearTextPassword" value="bar"/><add key="ValidAuthenticationTypes" value="basic"/></SourceCredentials></packageSourceCredentials></configuration>',
227227
'Helper should have added the "SourceCredentials" source with credentials');
228228

229229
helper.RemoveSourceFromNuGetConfig("SourceCredentials");
@@ -251,14 +251,14 @@ not xml
251251
helper.AddSourceToNuGetConfig("1Feed", "http://credentials", "foo", "bar");
252252
assert.strictEqual(
253253
configFile,
254-
'<configuration><packageSources><add key="1Feed" value="http://credentials"/></packageSources><packageSourceCredentials><_x0031_Feed><add key="Username" value="foo"/><add key="ClearTextPassword" value="bar"/></_x0031_Feed></packageSourceCredentials></configuration>',
254+
'<configuration><packageSources><add key="1Feed" value="http://credentials"/></packageSources><packageSourceCredentials><_x0031_Feed><add key="Username" value="foo"/><add key="ClearTextPassword" value="bar"/><add key="ValidAuthenticationTypes" value="basic"/></_x0031_Feed></packageSourceCredentials></configuration>',
255255
'Helper should have added the "1Feed" source with credentials');
256256
helper.RemoveSourceFromNuGetConfig("1Feed");
257257

258258
helper.AddSourceToNuGetConfig("Feed with spaces and :", "http://credentials", "foo", "bar");
259259
assert.strictEqual(
260260
configFile,
261-
'<configuration><packageSources><add key="Feed with spaces and :" value="http://credentials"/></packageSources><packageSourceCredentials><Feed_x0020_with_x0020_spaces_x0020_and_x0020__x003a_><add key="Username" value="foo"/><add key="ClearTextPassword" value="bar"/></Feed_x0020_with_x0020_spaces_x0020_and_x0020__x003a_></packageSourceCredentials></configuration>',
261+
'<configuration><packageSources><add key="Feed with spaces and :" value="http://credentials"/></packageSources><packageSourceCredentials><Feed_x0020_with_x0020_spaces_x0020_and_x0020__x003a_><add key="Username" value="foo"/><add key="ClearTextPassword" value="bar"/><add key="ValidAuthenticationTypes" value="basic"/></Feed_x0020_with_x0020_spaces_x0020_and_x0020__x003a_></packageSourceCredentials></configuration>',
262262
'Helper should have added the "Feed with spaces" source with credentials');
263263
helper.RemoveSourceFromNuGetConfig("Feed with spaces");
264264

Tasks/Common/packaging-common/bump-task-version.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Param(
1010
)
1111

1212
# Bump patch version and adjust sprint
13-
"DotNetCoreCLIV2","DownloadPackageV0","DownloadPackageV1","MavenV2","MavenV3","NpmV1","NpmAuthenticateV0","NuGetV0","NuGetCommandV2","NuGetPublisherV0","NuGetToolInstallerV0","NuGetToolInstallerV1","PipAuthenticateV0","TwineAuthenticateV0","UniversalPackagesV0", "UseNodeV1" | % {
13+
"DotNetCoreCLIV2","DownloadPackageV0","DownloadPackageV1","MavenV2","MavenV3","NpmV0","NpmV1","NpmAuthenticateV0","NuGetInstallerV0","NuGetV0","NuGetCommandV2","NuGetPublisherV0","NuGetToolInstallerV0","NuGetToolInstallerV1","PipAuthenticateV0","TwineAuthenticateV0","UniversalPackagesV0","UseNodeV1" | % {
1414
$taskLocation = Join-Path "$taskRoot/$_" "task.json"
1515
$taskContent = Get-Content $taskLocation
1616
$task = $taskContent | ConvertFrom-Json
@@ -37,7 +37,7 @@ Param(
3737
}
3838

3939
# Just bump the patch version for these.
40-
"UseDotNetV2" | % {
40+
"UseDotNetV2","DownloadGitHubNugetPackageV1","DownloadGitHubNpmPackageV1" | % {
4141
$taskLocation = Join-Path "$taskRoot/$_" "task.json"
4242
$taskContent = Get-Content $taskLocation
4343
$task = $taskContent | ConvertFrom-Json

Tasks/Common/packaging-common/module.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"Info_SavingTempConfig": "Saving NuGet.config to a temporary config file.",
1414
"Info_UsingToolPath": "Using tool path: %s",
1515
"Info_UsingVersion": "Using version: %s",
16+
"Info_BasicCredRestriction": "This task now configures NuGet to send these credentials using the Basic scheme\nonly. Most users will be unaffected by this change. If these are Windows domain\ncredentials and they have recently stopped working, try setting the build\nvariable %s to the value '%s' (without quotes).",
1617
"NGCommon_AddingSources": "Setting credentials in NuGet.config",
1718
"NGCommon_AreaNotFoundInSps": "Unable to locate the '%s' [%s] area. The service containing that area may not be available in your region.",
1819
"NGCommon_DetectedNuGetExtensionsPath": "Detected NuGet extensions loader path (NUGET_EXTENSIONS_PATH environment variable): %s",

Tasks/Common/packaging-common/nuget/NuGetConfigHelper2.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ export class NuGetConfigHelper2 {
8484
}
8585

8686
sources.forEach((source) => {
87+
tl.debug(`considering source ${source.feedUri}. Internal: ${source.isInternal}`)
8788
if (source.isInternal)
8889
{
8990
if(this.authInfo.internalAuthInfo.useCredConfig)
@@ -109,6 +110,7 @@ export class NuGetConfigHelper2 {
109110
{
110111
if (!this.authInfo.externalAuthInfo || this.authInfo.externalAuthInfo.length < 1)
111112
{
113+
tl.debug('No external auth information');
112114
return;
113115
}
114116

@@ -137,6 +139,8 @@ export class NuGetConfigHelper2 {
137139
default:
138140
break;
139141
}
142+
} else {
143+
tl.debug(`No auth information found for source ${source.feedUri}`);
140144
}
141145
}
142146
});

Tasks/Common/packaging-common/nuget/NuGetXmlHelper.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,20 @@ export class NuGetXmlHelper implements INuGetXmlHelper {
6060

6161
private _addCredentialsToSource(xml: any, name: string, username: string, password: string): any {
6262
if (xml) {
63-
let xmlSourceCredentials = NuGetXmlHelper._getOrCreateLastElement(xml, "packageSourceCredentials");
64-
let xmlFeedName = xmlSourceCredentials.c(NuGetXmlHelper._nuGetEncodeElementName(name));
63+
const xmlSourceCredentials = NuGetXmlHelper._getOrCreateLastElement(xml, "packageSourceCredentials");
64+
const encodedName = NuGetXmlHelper._nuGetEncodeElementName(name);
65+
const authTypesVar = "ValidAuthenticationTypes_" + encodedName;
66+
const xmlFeedName = xmlSourceCredentials.c(encodedName);
67+
68+
let authTypes = tl.getVariable(authTypesVar);
69+
if(!authTypes) {
70+
if(username !== "VssSessionToken") {
71+
console.log(tl.loc("Info_BasicCredRestriction", authTypesVar, 'negotiate,ntlm'));
72+
}
73+
74+
authTypes = 'basic';
75+
}
76+
6577
xmlFeedName.c("add", {
6678
key: "Username",
6779
value: username
@@ -70,6 +82,10 @@ export class NuGetXmlHelper implements INuGetXmlHelper {
7082
key: "ClearTextPassword",
7183
value: password
7284
});
85+
xmlFeedName.c("add", {
86+
key: "ValidAuthenticationTypes",
87+
value: authTypes
88+
});
7389
}
7490

7591
return xml;

Tasks/DotNetCoreCLIV2/dotnetcore.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ export class dotNetExe {
3434
}
3535

3636
public async execute() {
37+
tl.setResourcePath(path.join(__dirname, "node_modules", "packaging-common", "module.json"));
3738
tl.setResourcePath(path.join(__dirname, "task.json"));
39+
3840
this.setConsoleCodePage();
3941

4042
try {

Tasks/DotNetCoreCLIV2/task.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"version": {
1919
"Major": 2,
2020
"Minor": 170,
21-
"Patch": 0
21+
"Patch": 1
2222
},
2323
"minimumAgentVersion": "2.115.0",
2424
"instanceNameFormat": "dotnet $(command)",
@@ -570,4 +570,4 @@
570570
"NetCore3Update": "Info: Azure Pipelines hosted agents have been updated to contain .Net Core 3.x (3.0 and 3.1) SDK/Runtime along with 2.1. Unless you have locked down a SDK version for your project(s), 3.x SDK might be picked up which might have breaking behavior as compared to previous versions. \nSome commonly encountered changes are: \nIf you're using `Publish` command with -o or --Output argument, you will see that the output folder is now being created at root directory rather than Project File's directory. To learn about more such changes and troubleshoot, refer here: https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/build/dotnet-core-cli?view=azure-devops#troubleshooting",
571571
"DeprecatingDotnet2_2": ".NET Core SDK/runtime 2.2 is now End of Line(EOL) and will be removed from all agents by end of March, 2020. If you're using 2.2 SDK/runtime, kindly upgrade to newer versions which are not EOL or use UseDotNet task to install the requied version."
572572
}
573-
}
573+
}

Tasks/DotNetCoreCLIV2/task.loc.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"version": {
1919
"Major": 2,
2020
"Minor": 170,
21-
"Patch": 0
21+
"Patch": 1
2222
},
2323
"minimumAgentVersion": "2.115.0",
2424
"instanceNameFormat": "ms-resource:loc.instanceNameFormat",
@@ -570,4 +570,4 @@
570570
"NetCore3Update": "ms-resource:loc.messages.NetCore3Update",
571571
"DeprecatingDotnet2_2": "ms-resource:loc.messages.DeprecatingDotnet2_2"
572572
}
573-
}
573+
}

Tasks/DownloadGitHubNpmPackageV1/task.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"version": {
1111
"Major": 1,
1212
"Minor": 0,
13-
"Patch": 1
13+
"Patch": 3
1414
},
1515
"runsOn": [
1616
"Agent",
@@ -104,4 +104,4 @@
104104
"WorkingDirectoryNotDirectory": "Please change your working directory to a valid directory",
105105
"NGCommon_AreaNotFoundInSps": "Unable to locate the '%s' [%s] area. The service containing that area may not be available in your region."
106106
}
107-
}
107+
}

0 commit comments

Comments
 (0)