Skip to content

Commit 3a9d5a4

Browse files
authored
Merge pull request #117 from gapreste/add-analysisservices-environment-extension-case
Add token audience endpoints for analysis services environments.
2 parents fb96410 + ed64dfe commit 3a9d5a4

File tree

4 files changed

+41
-2
lines changed

4 files changed

+41
-2
lines changed

src/Authentication.Abstractions/AzureEnvironment.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ static IDictionary<string, AzureEnvironment> InitializeBuiltInEnvironments()
5454
azureCloud.SetProperty(ExtendedEndpoint.OperationalInsightsEndpoint, AzureEnvironmentConstants.AzureOperationalInsightsEndpoint);
5555
azureCloud.SetProperty(ExtendedEndpoint.OperationalInsightsEndpointResourceId, AzureEnvironmentConstants.AzureOperationalInsightsEndpointResourceId);
5656
azureCloud.SetProperty(ExtendedEndpoint.AnalysisServicesEndpointSuffix, AzureEnvironmentConstants.AzureAnalysisServicesEndpointSuffix);
57+
azureCloud.SetProperty(ExtendedEndpoint.AnalysisServicesEndpointResourceId, AzureEnvironmentConstants.AzureAnalysisServicesEndpointResourceId);
5758
var azureChina = new AzureEnvironment
5859
{
5960
Name = EnvironmentName.AzureChinaCloud,
@@ -78,6 +79,7 @@ static IDictionary<string, AzureEnvironment> InitializeBuiltInEnvironments()
7879
AdTenant = "Common"
7980
};
8081
azureChina.SetProperty(ExtendedEndpoint.AnalysisServicesEndpointSuffix, AzureEnvironmentConstants.ChinaAnalysisServicesEndpointSuffix);
82+
azureChina.SetProperty(ExtendedEndpoint.AnalysisServicesEndpointResourceId, AzureEnvironmentConstants.ChinaAnalysisServicesEndpointResourceId);
8183

8284
var azureUSGovernment = new AzureEnvironment
8385
{
@@ -105,6 +107,7 @@ static IDictionary<string, AzureEnvironment> InitializeBuiltInEnvironments()
105107
azureUSGovernment.SetProperty(ExtendedEndpoint.OperationalInsightsEndpoint, AzureEnvironmentConstants.USGovernmentOperationalInsightsEndpoint);
106108
azureUSGovernment.SetProperty(ExtendedEndpoint.OperationalInsightsEndpointResourceId, AzureEnvironmentConstants.USGovernmentOperationalInsightsEndpointResourceId);
107109
azureUSGovernment.SetProperty(ExtendedEndpoint.AnalysisServicesEndpointSuffix, AzureEnvironmentConstants.USGovernmentAnalysisServicesEndpointSuffix);
110+
azureUSGovernment.SetProperty(ExtendedEndpoint.AnalysisServicesEndpointResourceId, AzureEnvironmentConstants.USGovernmentAnalysisServicesEndpointResourceId);
108111
var azureGermany = new AzureEnvironment
109112
{
110113
Name = EnvironmentName.AzureGermanCloud,
@@ -129,6 +132,7 @@ static IDictionary<string, AzureEnvironment> InitializeBuiltInEnvironments()
129132
AdTenant = "Common"
130133
};
131134
azureGermany.SetProperty(ExtendedEndpoint.AnalysisServicesEndpointSuffix, AzureEnvironmentConstants.GermanAnalysisServicesEndpointSuffix);
135+
azureGermany.SetProperty(ExtendedEndpoint.AnalysisServicesEndpointResourceId, AzureEnvironmentConstants.GermanAnalysisServicesEndpointResourceId);
132136
var result = new ConcurrentDictionary<string, AzureEnvironment>(StringComparer.InvariantCultureIgnoreCase);
133137

134138
result[EnvironmentName.AzureCloud] = azureCloud;
@@ -302,7 +306,8 @@ public static class ExtendedEndpoint
302306
{
303307
public const string OperationalInsightsEndpointResourceId = "OperationalInsightsEndpointResourceId",
304308
OperationalInsightsEndpoint = "OperationalInsightsEndpoint",
305-
AnalysisServicesEndpointSuffix = "AzureAnalysisServicesEndpointSuffix";
309+
AnalysisServicesEndpointSuffix = "AzureAnalysisServicesEndpointSuffix",
310+
AnalysisServicesEndpointResourceId = "AnalysisServicesEndpointResourceId";
306311
}
307312
}
308313
}

src/Authentication.Abstractions/AzureEnvironmentConstants.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,5 +158,18 @@ public static class AzureEnvironmentConstants
158158
public const string ChinaAnalysisServicesEndpointSuffix = "asazure.chinacloudapi.cn";
159159
public const string USGovernmentAnalysisServicesEndpointSuffix = "asazure.usgovcloudapi.net";
160160
public const string GermanAnalysisServicesEndpointSuffix = "asazure.cloudapi.de";
161+
162+
/// <summary>
163+
/// The token audiences for authorizing Analysis Service requests
164+
/// </summary>
165+
/// <remarks>
166+
/// Analysis Service expects a token audience which matches "https://*.asazure.windows.net".
167+
/// The wildcard takes place of the region, however the region cannot be calculated here.
168+
/// "region" can take place of the region, since "*" is an invalid character for URIs.
169+
/// </remarks>
170+
public const string AzureAnalysisServicesEndpointResourceId = "https://region.asazure.windows.net";
171+
public const string ChinaAnalysisServicesEndpointResourceId = "https://region.asazure.chinacloudapi.cn";
172+
public const string USGovernmentAnalysisServicesEndpointResourceId = "https://region.asazure.usgovcloudapi.net";
173+
public const string GermanAnalysisServicesEndpointResourceId = "https://region.asazure.cloudapi.de";
161174
}
162175
}

src/Authentication.Abstractions/Extensions/AzureEnvironmentExtensions.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,9 @@ public static void SetEndpoint(this IAzureEnvironment environment, string endpoi
274274
case AzureEnvironment.ExtendedEndpoint.AnalysisServicesEndpointSuffix:
275275
environment.SetProperty(AzureEnvironment.ExtendedEndpoint.AnalysisServicesEndpointSuffix, propertyValue);
276276
break;
277-
277+
case AzureEnvironment.ExtendedEndpoint.AnalysisServicesEndpointResourceId:
278+
environment.SetProperty(AzureEnvironment.ExtendedEndpoint.AnalysisServicesEndpointResourceId, propertyValue);
279+
break;
278280
}
279281
}
280282
}
@@ -306,6 +308,10 @@ public static string GetTokenAudience(this IAzureEnvironment environment, string
306308
case AzureEnvironment.ExtendedEndpoint.OperationalInsightsEndpointResourceId:
307309
resource = AzureEnvironment.ExtendedEndpoint.OperationalInsightsEndpointResourceId;
308310
break;
311+
case AzureEnvironment.ExtendedEndpoint.AnalysisServicesEndpointSuffix:
312+
case AzureEnvironment.ExtendedEndpoint.AnalysisServicesEndpointResourceId:
313+
resource = AzureEnvironment.ExtendedEndpoint.AnalysisServicesEndpointResourceId;
314+
break;
309315
default:
310316
resource = AzureEnvironment.Endpoint.ActiveDirectoryServiceEndpointResourceId;
311317
break;

src/Authentication.ResourceManager/Models/PSAzureEnvironment.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,21 @@ public string AzureAnalysisServicesEndpointSuffix
276276
}
277277
}
278278

279+
/// <summary>
280+
/// Gets or sets the resource Id to use for contacting the analysis services endpoint
281+
/// </summary>
282+
public string AnalysisServicesEndpointResourceId
283+
{
284+
get
285+
{
286+
return this.GetEndpointSuffix(AzureEnvironment.ExtendedEndpoint.AnalysisServicesEndpointResourceId);
287+
}
288+
set
289+
{
290+
this.SetEndpoint(AzureEnvironment.ExtendedEndpoint.AnalysisServicesEndpointResourceId, value);
291+
}
292+
}
293+
279294
public IList<string> VersionProfiles { get; } = new List<string>();
280295

281296
public IDictionary<string, string> ExtendedProperties { get; } = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);

0 commit comments

Comments
 (0)