azure-pipelines-tasks-azurermdeploycommon 3.221.1 → 3.221.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -141,17 +141,35 @@ class AzureAppServiceUtility {
141
141
  getKuduAuthHeader(publishingCredentials) {
142
142
  return __awaiter(this, void 0, void 0, function* () {
143
143
  const scmPolicyCheck = yield this.isSitePublishingCredentialsEnabled();
144
+ let token = "";
145
+ let method = "";
146
+ const password = publishingCredentials.properties["publishingPassword"];
147
+ const userName = publishingCredentials.properties["publishingUserName"];
144
148
  if (scmPolicyCheck === false) {
145
- tl.debug('Kudu: Getting Bearer token');
146
- const accessToken = yield this._appService._client.getCredentials().getToken();
147
- return "Bearer " + accessToken;
149
+ token = yield this._appService._client.getCredentials().getToken();
150
+ method = "Bearer";
151
+ // Though bearer AuthN is used, lets try to set publish profile password for mask hints to maintain compat with old behavior for MSDEPLOY.
152
+ // This needs to be cleaned up once MSDEPLOY suppport is reomve. Safe handle the exception setting up mask hint as we dont want to fail here.
153
+ try {
154
+ tl.setVariable(`AZURE_APP_MSDEPLOY_${this._appService.getSlot()}_PASSWORD`, password, true);
155
+ }
156
+ catch (error) {
157
+ // safe handle the exception setting up mask hint
158
+ tl.debug(`Setting mask hint for publish profile password failed with error: ${error}`);
159
+ }
148
160
  }
149
161
  else {
150
- tl.setVariable(`AZURE_APP_SERVICE_KUDU_${this._appService.getSlot()}_PASSWORD`, publishingCredentials.properties["publishingPassword"], true);
151
- var accessToken = (new Buffer(publishingCredentials.properties["publishingUserName"] + ':' + publishingCredentials.properties["publishingPassword"]).toString('base64'));
152
- tl.debug("Kudu: using basic auth.");
153
- return "Basic " + accessToken;
162
+ tl.setVariable(`AZURE_APP_SERVICE_KUDU_${this._appService.getSlot()}_PASSWORD`, password, true);
163
+ const buffer = new Buffer(userName + ':' + password);
164
+ token = buffer.toString('base64');
165
+ method = "Basic";
154
166
  }
167
+ const authMethodtelemetry = {
168
+ authMethod: method
169
+ };
170
+ tl.debug(`Using ${method} authentication method for Kudu service.`);
171
+ console.log("##vso[telemetry.publish area=TaskDeploymentMethod;feature=AzureAppServiceDeployment]" + JSON.stringify(authMethodtelemetry));
172
+ return method + " " + token;
155
173
  });
156
174
  }
157
175
  getPhysicalPath(virtualApplication) {
@@ -134,17 +134,41 @@ export class AzureAppServiceUtility {
134
134
  private async getKuduAuthHeader(publishingCredentials: any): Promise<string> {
135
135
  const scmPolicyCheck = await this.isSitePublishingCredentialsEnabled();
136
136
 
137
+ let token = "";
138
+ let method = "";
139
+
140
+ const password = publishingCredentials.properties["publishingPassword"];
141
+ const userName = publishingCredentials.properties["publishingUserName"];
142
+
137
143
  if(scmPolicyCheck === false) {
138
- tl.debug('Kudu: Getting Bearer token');
139
- const accessToken = await this._appService._client.getCredentials().getToken();
140
- return "Bearer " + accessToken;
141
- } else {
142
- tl.setVariable(`AZURE_APP_SERVICE_KUDU_${this._appService.getSlot()}_PASSWORD`, publishingCredentials.properties["publishingPassword"], true);
143
- var accessToken = (new Buffer(publishingCredentials.properties["publishingUserName"] + ':' + publishingCredentials.properties["publishingPassword"]).toString('base64'));
144
- tl.debug("Kudu: using basic auth.");
144
+ token = await this._appService._client.getCredentials().getToken();
145
+ method = "Bearer";
146
+
147
+
148
+ // Though bearer AuthN is used, lets try to set publish profile password for mask hints to maintain compat with old behavior for MSDEPLOY.
149
+ // This needs to be cleaned up once MSDEPLOY suppport is reomve. Safe handle the exception setting up mask hint as we dont want to fail here.
150
+ try {
151
+ tl.setVariable(`AZURE_APP_MSDEPLOY_${this._appService.getSlot()}_PASSWORD`, password, true);
152
+ }
153
+ catch (error) {
154
+ // safe handle the exception setting up mask hint
155
+ tl.debug(`Setting mask hint for publish profile password failed with error: ${error}`);
156
+ }
145
157
 
146
- return "Basic " + accessToken;
158
+ } else {
159
+ tl.setVariable(`AZURE_APP_SERVICE_KUDU_${this._appService.getSlot()}_PASSWORD`, password, true);
160
+ const buffer = new Buffer(userName + ':' + password);
161
+ token = buffer.toString('base64');
162
+ method = "Basic";
147
163
  }
164
+
165
+ const authMethodtelemetry = {
166
+ authMethod: method
167
+ };
168
+ tl.debug(`Using ${method} authentication method for Kudu service.`);
169
+ console.log("##vso[telemetry.publish area=TaskDeploymentMethod;feature=AzureAppServiceDeployment]" + JSON.stringify(authMethodtelemetry));
170
+
171
+ return method + " " + token;
148
172
  }
149
173
 
150
174
  public async getPhysicalPath(virtualApplication: string): Promise<string> {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "azure-pipelines-tasks-azurermdeploycommon",
3
- "version": "3.221.1",
3
+ "version": "3.221.3",
4
4
  "description": "Common Lib for Azure ARM REST apis",
5
5
  "repository": {
6
6
  "type": "git",