Skip to content

Commit 2d04a99

Browse files
Merge branch 'nebharg/MSI' into nebharg/MsiAzureArc
2 parents 524548f + 2ff1b2c commit 2d04a99

Some content is hidden

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

47 files changed

+703
-482
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Quick links:
1616
The library supports the following Java environments:
1717
- Java 8 (or higher)
1818

19-
Current version - 1.13.10
19+
Current version - 1.14.2-beta
2020

2121
You can find the changes for each version in the [change log](https://github.com/AzureAD/microsoft-authentication-library-for-java/blob/main/msal4j-sdk/changelog.txt).
2222

@@ -28,13 +28,13 @@ Find [the latest package in the Maven repository](https://mvnrepository.com/arti
2828
<dependency>
2929
<groupId>com.microsoft.azure</groupId>
3030
<artifactId>msal4j</artifactId>
31-
<version>1.13.10</version>
31+
<version>1.14.2-beta</version>
3232
</dependency>
3333
```
3434
### Gradle
3535

3636
```gradle
37-
implementation group: 'com.microsoft.azure', name: 'com.microsoft.aad.msal4j', version: '1.13.10'
37+
implementation group: 'com.microsoft.azure', name: 'com.microsoft.aad.msal4j', version: '1.14.2-beta'
3838
```
3939

4040
## Usage

changelog.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
Version 1.14.2-beta
2+
=============
3+
- Add support for Managed Identity (#712)
4+
15
Version 1.13.10
26
=============
37
- Remove default HTTP timeout (#664)

msal4j-sdk/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Quick links:
1616
The library supports the following Java environments:
1717
- Java 8 (or higher)
1818

19-
Current version - 1.13.10
19+
Current version - 1.14.2-beta
2020

2121
You can find the changes for each version in the [change log](https://github.com/AzureAD/microsoft-authentication-library-for-java/blob/master/changelog.txt).
2222

@@ -28,13 +28,13 @@ Find [the latest package in the Maven repository](https://mvnrepository.com/arti
2828
<dependency>
2929
<groupId>com.microsoft.azure</groupId>
3030
<artifactId>msal4j</artifactId>
31-
<version>1.13.10</version>
31+
<version>1.14.2-beta</version>
3232
</dependency>
3333
```
3434
### Gradle
3535

3636
```gradle
37-
compile group: 'com.microsoft.azure', name: 'msal4j', version: '1.13.10'
37+
compile group: 'com.microsoft.azure', name: 'msal4j', version: '1.14.2-beta'
3838
```
3939

4040
## Usage

msal4j-sdk/bnd.bnd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Export-Package: com.microsoft.aad.msal4j;version="1.13.10"
1+
Export-Package: com.microsoft.aad.msal4j;version="1.14.2-beta"
22
Automatic-Module-Name: com.microsoft.aad.msal4j

msal4j-sdk/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>com.microsoft.azure</groupId>
55
<artifactId>msal4j</artifactId>
6-
<version>1.13.10</version>
6+
<version>1.14.2-beta</version>
77
<packaging>jar</packaging>
88
<name>msal4j</name>
99
<description>

msal4j-sdk/src/integrationtest/java/com.microsoft.aad.msal4j/AcquireTokenSilentIT.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ void acquireTokenSilent_LabAuthority_TokenNotRefreshed(String environment) throw
6969
// Check that access and id tokens are coming from cache
7070
assertEquals(result.accessToken(), acquireSilentResult.accessToken());
7171
assertEquals(result.idToken(), acquireSilentResult.idToken());
72+
assertEquals(TokenSource.IDENTITY_PROVIDER, result.metadata().tokenSource());
73+
assertEquals(TokenSource.CACHE, acquireSilentResult.metadata().tokenSource());
7274
}
7375

7476
@ParameterizedTest
@@ -92,6 +94,8 @@ void acquireTokenSilent_ForceRefresh(String environment) throws Exception {
9294

9395
// Check that new refresh and id tokens are being returned
9496
assertTokensAreNotEqual(result, resultAfterRefresh);
97+
assertEquals(TokenSource.IDENTITY_PROVIDER, result.metadata().tokenSource());
98+
assertEquals(TokenSource.IDENTITY_PROVIDER, resultAfterRefresh.metadata().tokenSource());
9599
}
96100

97101
@ParameterizedTest
@@ -253,6 +257,8 @@ void acquireTokenSilent_WithRefreshOn(String environment) throws Exception {
253257
//Current time is after refreshOn, so token should be refreshed
254258
assertNotNull(resultSilentWithRefreshOn);
255259
assertTokensAreNotEqual(resultSilent, resultSilentWithRefreshOn);
260+
assertEquals(TokenSource.CACHE, resultSilent.metadata().tokenSource());
261+
assertEquals(TokenSource.IDENTITY_PROVIDER, resultSilentWithRefreshOn.metadata().tokenSource());
256262
}
257263

258264
@ParameterizedTest

msal4j-sdk/src/main/java/com/microsoft/aad/msal4j/AadInstanceDiscoveryProvider.java

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,29 +64,35 @@ static InstanceDiscoveryMetadataEntry getMetadataEntry(URL authorityUrl,
6464
ServiceBundle serviceBundle) {
6565
String host = authorityUrl.getHost();
6666

67-
if (shouldUseRegionalEndpoint(msalRequest)) {
67+
if (msalRequest.application() instanceof AbstractClientApplicationBase && shouldUseRegionalEndpoint(msalRequest)) {
6868
//Server side telemetry requires the result from region discovery when any part of the region API is used
6969
String detectedRegion = discoverRegion(msalRequest, serviceBundle);
7070

71-
if (msalRequest.application().azureRegion() != null) {
72-
host = getRegionalizedHost(authorityUrl.getHost(), msalRequest.application().azureRegion());
71+
if (((AbstractClientApplicationBase) msalRequest.application()).azureRegion() != null) {
72+
host = getRegionalizedHost(authorityUrl.getHost(),
73+
((AbstractClientApplicationBase) msalRequest.application()).azureRegion());
7374
}
7475

7576
//If region autodetection is enabled and a specific region not already set,
7677
// set the application's region to the discovered region so that future requests can skip the IMDS endpoint call
77-
if (null == msalRequest.application().azureRegion() && msalRequest.application().autoDetectRegion()
78+
if (null == ((AbstractClientApplicationBase) msalRequest.application()).azureRegion()
79+
&& ((AbstractClientApplicationBase) msalRequest.application()).autoDetectRegion()
7880
&& null != detectedRegion) {
79-
msalRequest.application().azureRegion = detectedRegion;
81+
((AbstractClientApplicationBase) msalRequest.application()).azureRegion = detectedRegion;
8082
}
81-
cacheRegionInstanceMetadata(authorityUrl.getHost(), msalRequest.application().azureRegion());
83+
cacheRegionInstanceMetadata(authorityUrl.getHost(), ((AbstractClientApplicationBase) msalRequest.application()).azureRegion());
8284
serviceBundle.getServerSideTelemetry().getCurrentRequest().regionOutcome(
83-
determineRegionOutcome(detectedRegion, msalRequest.application().azureRegion(), msalRequest.application().autoDetectRegion()));
85+
determineRegionOutcome(detectedRegion,
86+
((AbstractClientApplicationBase) msalRequest.application()).azureRegion(),
87+
((AbstractClientApplicationBase) msalRequest.application()).autoDetectRegion()));
8488
}
8589

8690
InstanceDiscoveryMetadataEntry result = cache.get(host);
8791

8892
if (result == null) {
89-
if(msalRequest.application().instanceDiscovery() && !instanceDiscoveryFailed){
93+
if(msalRequest.application() instanceof AbstractClientApplicationBase &&
94+
((AbstractClientApplicationBase) msalRequest.application()).instanceDiscovery()
95+
&& !instanceDiscoveryFailed){
9096
doInstanceDiscoveryAndCache(authorityUrl, validateAuthority, msalRequest, serviceBundle);
9197
} else {
9298
// instanceDiscovery flag is set to False. Do not perform instanceDiscovery.
@@ -145,7 +151,8 @@ static void cacheInstanceDiscoveryMetadata(String host,
145151

146152

147153
private static boolean shouldUseRegionalEndpoint(MsalRequest msalRequest){
148-
if (msalRequest.application().azureRegion() != null || msalRequest.application().autoDetectRegion()){
154+
if (((AbstractClientApplicationBase) msalRequest.application()).azureRegion() != null
155+
|| ((AbstractClientApplicationBase) msalRequest.application()).autoDetectRegion()){
149156
//This class type check is a quick and dirty fix to accommodate changes to the internal workings of the region API
150157
//
151158
//ESTS-R only supports a small, but growing, number of scenarios, and the original design failed silently whenever

0 commit comments

Comments
 (0)