Skip to content

Commit b9c9e55

Browse files
authored
Hard code authorization scope for all ADT instances. (Azure#17226)
* Hard code authorization scope for all ADT instances. * Update CHANGELOG.md * Release preparation * Update README.md
1 parent 913fe0f commit b9c9e55

File tree

6 files changed

+9
-18
lines changed

6 files changed

+9
-18
lines changed

eng/jacoco-test-coverage/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@
526526
<dependency>
527527
<groupId>com.azure</groupId>
528528
<artifactId>azure-digitaltwins-core</artifactId>
529-
<version>1.1.0-beta.1</version> <!-- {x-version-update;com.azure:azure-digitaltwins-core;current} -->
529+
<version>1.0.1</version> <!-- {x-version-update;com.azure:azure-digitaltwins-core;current} -->
530530
</dependency>
531531
</dependencies>
532532
<build>

eng/versioning/version_client.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ com.azure:azure-data-appconfiguration;1.1.6;1.2.0-beta.1
5656
com.azure:azure-data-schemaregistry;1.0.0-beta.4;1.0.0-beta.5
5757
com.azure:azure-data-schemaregistry-avro;1.0.0-beta.4;1.0.0-beta.5
5858
com.azure:azure-data-tables;12.0.0-beta.2;12.0.0-beta.3
59-
com.azure:azure-digitaltwins-core;1.0.0;1.1.0-beta.1
59+
com.azure:azure-digitaltwins-core;1.0.0;1.0.1
6060
com.azure:azure-e2e;1.0.0-beta.1;1.0.0-beta.1
6161
com.azure:azure-identity;1.1.3;1.2.0-beta.3
6262
com.azure:azure-identity-perf;1.0.0-beta.1;1.0.0-beta.1

sdk/digitaltwins/azure-digitaltwins-core/CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
# Release History
22

3-
## 1.1.0-beta.1 (Unreleased)
3+
## 1.0.1 (2020-11-05)
44

5+
### Fixes and improvements
6+
7+
- Removed logic to determine authorization scope based on digital twins instance URI.
58

69
## 1.0.0 (2020-10-30)
710

sdk/digitaltwins/azure-digitaltwins-core/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ For the best development experience, developers should use the official Microsof
1818
<dependency>
1919
<groupId>com.azure</groupId>
2020
<artifactId>azure-digitaltwins-core</artifactId>
21-
<version>1.0.0</version>
21+
<version>1.0.1</version>
2222
</dependency>
2323
```
2424

sdk/digitaltwins/azure-digitaltwins-core/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
<groupId>com.azure</groupId>
1515
<artifactId>azure-digitaltwins-core</artifactId>
16-
<version>1.1.0-beta.1</version> <!-- {x-version-update;com.azure:azure-digitaltwins-core;current} -->
16+
<version>1.0.1</version> <!-- {x-version-update;com.azure:azure-digitaltwins-core;current} -->
1717

1818
<name>Microsoft Azure client library for Digital Twins</name>
1919
<description>This package contains the Microsoft Azure DigitalTwins client library.</description>

sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DigitalTwinsClientBuilder.java

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@
3939
*/
4040
@ServiceClientBuilder(serviceClients = {DigitalTwinsClient.class, DigitalTwinsAsyncClient.class})
4141
public final class DigitalTwinsClientBuilder {
42-
43-
private static final Pattern ADT_PUBLIC_SCOPE_VALIDATION_PATTERN = Pattern.compile("(ppe|azure)\\.net");
4442
private static final String[] ADT_PUBLIC_SCOPE = new String[]{"https://digitaltwins.azure.net" + "/.default"};
4543

4644
// This is the name of the properties file in this repo that contains the default properties
@@ -124,7 +122,7 @@ private static HttpPipeline buildPipeline(TokenCredential tokenCredential,
124122
policies.add(new AddDatePolicy());
125123

126124
// Add authentication policy so that each HTTP request has authorization header
127-
HttpPipelinePolicy credentialPolicy = new BearerTokenAuthenticationPolicy(tokenCredential, getAuthorizationScopes(endpoint));
125+
HttpPipelinePolicy credentialPolicy = new BearerTokenAuthenticationPolicy(tokenCredential, ADT_PUBLIC_SCOPE);
128126
policies.add(credentialPolicy);
129127

130128
policies.addAll(additionalPolicies);
@@ -153,16 +151,6 @@ private static HttpPipeline buildPipeline(TokenCredential tokenCredential,
153151
.build();
154152
}
155153

156-
private static String[] getAuthorizationScopes(String endpoint) {
157-
// If the endpoint is in Azure public cloud, the suffix will have "azure.net" or "ppe.net".
158-
// Once ADT becomes available in other clouds, their corresponding scope has to be matched and set.
159-
if (ADT_PUBLIC_SCOPE_VALIDATION_PATTERN.matcher(endpoint).find()) {
160-
return ADT_PUBLIC_SCOPE;
161-
}
162-
163-
throw new IllegalArgumentException(String.format("Azure digital twins instance endpoint %s is not valid.", endpoint));
164-
}
165-
166154
/**
167155
* Create a {@link DigitalTwinsClient} based on the builder settings.
168156
*

0 commit comments

Comments
 (0)