azure-pipelines-tasks-azurermdeploycommon 3.219.0 → 3.221.0

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.
Files changed (30) hide show
  1. package/Strings/resources.resjson/de-DE/resources.resjson +69 -69
  2. package/Strings/resources.resjson/es-ES/resources.resjson +58 -58
  3. package/Strings/resources.resjson/fr-FR/resources.resjson +84 -84
  4. package/Strings/resources.resjson/it-IT/resources.resjson +36 -36
  5. package/Strings/resources.resjson/ja-JP/resources.resjson +32 -32
  6. package/Strings/resources.resjson/ko-KR/resources.resjson +25 -25
  7. package/Strings/resources.resjson/ru-RU/resources.resjson +52 -52
  8. package/Strings/resources.resjson/zh-CN/resources.resjson +1 -1
  9. package/Strings/resources.resjson/zh-TW/resources.resjson +28 -28
  10. package/Tests/azure-arm-app-service-kudu-tests.js +35 -35
  11. package/Tests/azure-arm-app-service-kudu-tests.ts +35 -35
  12. package/azure-arm-rest/Strings/resources.resjson/de-DE/resources.resjson +61 -61
  13. package/azure-arm-rest/Strings/resources.resjson/es-ES/resources.resjson +49 -49
  14. package/azure-arm-rest/Strings/resources.resjson/fr-FR/resources.resjson +80 -80
  15. package/azure-arm-rest/Strings/resources.resjson/it-IT/resources.resjson +33 -33
  16. package/azure-arm-rest/Strings/resources.resjson/ja-JP/resources.resjson +31 -31
  17. package/azure-arm-rest/Strings/resources.resjson/ko-KR/resources.resjson +23 -23
  18. package/azure-arm-rest/Strings/resources.resjson/ru-RU/resources.resjson +51 -51
  19. package/azure-arm-rest/Strings/resources.resjson/zh-CN/resources.resjson +1 -1
  20. package/azure-arm-rest/Strings/resources.resjson/zh-TW/resources.resjson +26 -26
  21. package/azure-arm-rest/azure-arm-app-service-kudu.d.ts +3 -3
  22. package/azure-arm-rest/azure-arm-app-service-kudu.js +5 -6
  23. package/azure-arm-rest/azure-arm-app-service-kudu.ts +6 -7
  24. package/azure-arm-rest/azure-arm-app-service.d.ts +1 -0
  25. package/azure-arm-rest/azure-arm-app-service.js +21 -0
  26. package/azure-arm-rest/azure-arm-app-service.ts +23 -0
  27. package/operations/AzureAppServiceUtility.d.ts +2 -0
  28. package/operations/AzureAppServiceUtility.js +42 -5
  29. package/operations/AzureAppServiceUtility.ts +47 -6
  30. package/package.json +1 -1
@@ -118,14 +118,36 @@ export class AzureAppServiceUtility {
118
118
  }
119
119
  }
120
120
 
121
- public async getKuduService(): Promise<Kudu> {
122
- var publishingCredentials = await this._appService.getPublishingCredentials();
123
- if(publishingCredentials.properties["scmUri"]) {
124
- tl.setVariable(`AZURE_APP_SERVICE_KUDU_${this._appService.getSlot()}_PASSWORD`, publishingCredentials.properties["publishingPassword"], true);
125
- return new Kudu(publishingCredentials.properties["scmUri"], publishingCredentials.properties["publishingUserName"], publishingCredentials.properties["publishingPassword"]);
121
+ public async getKuduService(): Promise<Kudu> {
122
+
123
+ const publishingCredentials = await this._appService.getPublishingCredentials();
124
+ const scmUri = publishingCredentials.properties["scmUri"];
125
+
126
+ if (!scmUri) {
127
+ throw Error(tl.loc('KuduSCMDetailsAreEmpty'));
128
+ }
129
+
130
+ const authHeader = await this.getKuduAuthHeader(publishingCredentials);
131
+ return new Kudu(publishingCredentials.properties["scmUri"], authHeader);
132
+ }
133
+
134
+ private async getKuduAuthHeader(publishingCredentials: any): Promise<string> {
135
+ const scmPolicyCheck = await this.isSitePublishingCredentialsEnabled();
136
+
137
+ if (!scmPolicyCheck) {
138
+ const accessToken = await this._appService._client.getCredentials().getToken();
139
+ tl.debug("Kudu: using bearer token.");
140
+ return "Bearer " + accessToken;
126
141
  }
127
142
 
128
- throw Error(tl.loc('KuduSCMDetailsAreEmpty'));
143
+ const password = publishingCredentials.properties["publishingPassword"];
144
+ const userName = publishingCredentials.properties["publishingUserName"];
145
+
146
+ tl.setVariable(`AZURE_APP_SERVICE_KUDU_${this._appService.getSlot()}_PASSWORD`, password, true);
147
+ tl.debug("Kudu: using basic auth.");
148
+
149
+ const auth = (new Buffer(userName + ':' + password).toString('base64'));
150
+ return "Basic " + auth;
129
151
  }
130
152
 
131
153
  public async getPhysicalPath(virtualApplication: string): Promise<string> {
@@ -273,6 +295,25 @@ export class AzureAppServiceUtility {
273
295
  }
274
296
  }
275
297
 
298
+ public async isSitePublishingCredentialsEnabled(): Promise<boolean>{
299
+ try{
300
+ let scmAuthPolicy: any = await this._appService.getSitePublishingCredentialPolicies();
301
+ tl.debug(`Site Publishing Policy check: ${JSON.stringify(scmAuthPolicy)}`);
302
+ if(scmAuthPolicy && scmAuthPolicy.properties.allow) {
303
+ tl.debug("Function App does allow SCM access");
304
+ return true;
305
+ }
306
+ else {
307
+ tl.debug("Function App does not allow SCM Access");
308
+ return false;
309
+ }
310
+ }
311
+ catch(error){
312
+ tl.debug(`Skipping SCM Policy check: ${error}`);
313
+ return null;
314
+ }
315
+ }
316
+
276
317
  private async _getPhysicalToVirtualPathMap(virtualApplication: string): Promise<any> {
277
318
  // construct URL depending on virtualApplication or root of webapplication
278
319
  var physicalPath = null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "azure-pipelines-tasks-azurermdeploycommon",
3
- "version": "3.219.0",
3
+ "version": "3.221.0",
4
4
  "description": "Common Lib for Azure ARM REST apis",
5
5
  "repository": {
6
6
  "type": "git",