Skip to content

Commit 050d188

Browse files
Avery-DunnSomkaPesangonzaldependabot[bot]ShannonCanTech
authored
1.10.1 Release (#406)
* Pesomka/b2b stage1 (#356) multi cloud accounts * Pesomka/key store provider (#358) general purpose API should not be tied to specific security provider * Instance aware support (#362) Instance aware support for interactive requests * Update telemetry to reduce size of payload (#361) * Update telemetry implementation * Bump guava from 26.0-jre to 29.0-jre (#366) Bumps [guava](https://github.com/google/guava) from 26.0-jre to 29.0-jre. * Bump guava from 26.0-jre to 29.0-jre in /src/samples/msal-obo-sample (#367) Bumps [guava](https://github.com/google/guava) from 26.0-jre to 29.0-jre. * survey added to README.md Loyalty developer survey added to README.md Link placed in tab and new feedback section. * Update oauth2-oidc-sdk dependency (#373) Upgrade oauth2-oidc-sdk dependency * Add default cache lookup to client credential flow (#368) * Add default cache lookup to client credential flow * Bump commons-io from 2.6 to 2.7 (#376) Bumps commons-io from 2.6 to 2.7. * Sagonzal/update client credentials (#377) * Update obo flow to attempt cache lookup by default * 1.10.0 release * fix for issue with common scopes override (#385) fix for issue with common scopes override * Add ccs routing headers. Add option to pass in header map * Rename IApiParameters to IAcquireTokenParameters * PR Feedback * Add CCS routing information to /authorize query parameters * Update log levels for operations in OBO and ClientCredential supliers * Update how non 200 http response are handled. Update to only throw MsalExceptions * Update unit tests * Retrigger build * Update unit test * Bump httpclient from 4.5.9 to 4.5.13 (#401) Bumps httpclient from 4.5.9 to 4.5.13. --- updated-dependencies: - dependency-name: org.apache.httpcomponents:httpclient dependency-type: direct:development ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Improve region support and add region telemetry (#388) * Improve region support and add region telemetry * Finish implementation of most recent telemetry design * Update oauth dependency * Address code review comments * integration test for cross cloud b2b (#396) integration test for cross cloud b2b * Version and changelog updates for release 1.10.1 (#405) * Fix merge conflicts Co-authored-by: SomkaPe <[email protected]> Co-authored-by: Santiago Gonzalez <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: ShannonCanTech <[email protected]> Co-authored-by: Santiago Gonzalez <[email protected]>
1 parent e1d96e7 commit 050d188

File tree

63 files changed

+1076
-322
lines changed

Some content is hidden

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

63 files changed

+1076
-322
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.10.0
19+
Current version - 1.10.1
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.10.0</version>
31+
<version>1.10.1</version>
3232
</dependency>
3333
```
3434
### Gradle
3535

3636
```
37-
compile group: 'com.microsoft.azure', name: 'msal4j', version: '1.10.0'
37+
compile group: 'com.microsoft.azure', name: 'msal4j', version: '1.10.1'
3838
```
3939

4040
## Usage

changelog.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
Version 1.10.1
2+
=============
3+
- Improved behavior when using regional authorities
4+
- Fix scope override issue in OBO flow
5+
- Update server-side telemetry
6+
- Adjusted logging levels to reduce noise
7+
- Improved HTTP error handling and messaging
8+
- Upgrade oauth2-oidc-sdk dependency 9.4 -> 9.7
9+
- Upgrade httpclient dependency 4.5.9 -> 4.5.13
10+
111
Version 1.10.0
212
=============
313
- Instance aware support for interactive requests

pom.xml

Lines changed: 3 additions & 3 deletions
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.10.0</version>
6+
<version>1.10.1</version>
77
<packaging>jar</packaging>
88
<name>msal4j</name>
99
<description>
@@ -36,7 +36,7 @@
3636
<dependency>
3737
<groupId>com.nimbusds</groupId>
3838
<artifactId>oauth2-oidc-sdk</artifactId>
39-
<version>9.4</version>
39+
<version>9.7</version>
4040
</dependency>
4141
<dependency>
4242
<groupId>org.slf4j</groupId>
@@ -95,7 +95,7 @@
9595
<dependency>
9696
<groupId>org.apache.httpcomponents</groupId>
9797
<artifactId>httpclient</artifactId>
98-
<version>4.5.9</version>
98+
<version>4.5.13</version>
9999
<scope>test</scope>
100100
</dependency>
101101
<dependency>

src/integrationtest/java/com.microsoft.aad.msal4j/AcquireTokenInteractiveIT.java

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import java.net.URI;
1717
import java.net.URL;
1818
import java.util.Collections;
19+
import java.util.concurrent.ExecutionException;
1920

2021
public class AcquireTokenInteractiveIT extends SeleniumTest {
2122
private final static Logger LOG = LoggerFactory.getLogger(AuthorizationCodeIT.class);
@@ -168,6 +169,52 @@ private void assertAcquireTokenInstanceAware(User user) {
168169
Assert.assertEquals(result.account().environment(), pca.getAccounts().join().iterator().next().environment());
169170
}
170171

172+
@Test
173+
public void acquireTokensInHomeAndGuestClouds_ArlingtonAccount() throws MalformedURLException, ExecutionException, InterruptedException {
174+
acquireTokensInHomeAndGuestClouds(AzureEnvironment.AZURE_US_GOVERNMENT, TestConstants.AUTHORITY_ARLINGTON);
175+
}
176+
177+
@Test
178+
public void acquireTokensInHomeAndGuestClouds_MooncakeAccount() throws MalformedURLException, ExecutionException, InterruptedException {
179+
acquireTokensInHomeAndGuestClouds(AzureEnvironment.AZURE_CHINA, TestConstants.AUTHORITY_MOONCAKE);
180+
}
181+
182+
public void acquireTokensInHomeAndGuestClouds(String homeCloud, String homeCloudAuthority) throws MalformedURLException, ExecutionException, InterruptedException {
183+
184+
User user = labUserProvider.getUserByGuestHomeAzureEnvironments
185+
(AzureEnvironment.AZURE, homeCloud);
186+
187+
// use user`s upn from home cloud
188+
user.setUpn(user.getHomeUPN());
189+
190+
ITokenCacheAccessAspect persistenceAspect = new ITokenCacheAccessAspect() {
191+
String data;
192+
@Override
193+
public void beforeCacheAccess(ITokenCacheAccessContext iTokenCacheAccessContext) {
194+
iTokenCacheAccessContext.tokenCache().deserialize(data);
195+
}
196+
@Override
197+
public void afterCacheAccess(ITokenCacheAccessContext iTokenCacheAccessContext) {
198+
data = iTokenCacheAccessContext.tokenCache().serialize();
199+
}
200+
};
201+
202+
PublicClientApplication publicCloudPca = PublicClientApplication.builder(
203+
user.getAppId()).
204+
authority(TestConstants.AUTHORITY_PUBLIC_TENANT_SPECIFIC).setTokenCacheAccessAspect(persistenceAspect).
205+
build();
206+
207+
IAuthenticationResult result = acquireTokenInteractive(user, publicCloudPca, TestConstants.USER_READ_SCOPE);
208+
Assert.assertNotNull(result);
209+
Assert.assertNotNull(result.accessToken());
210+
Assert.assertNotNull(result.idToken());
211+
Assert.assertEquals(user.getHomeUPN(), result.account().username());
212+
213+
publicCloudPca.removeAccount(publicCloudPca.getAccounts().join().iterator().next()).join();
214+
215+
Assert.assertEquals(publicCloudPca.getAccounts().join().size(), 0);
216+
}
217+
171218
private IAuthenticationResult acquireTokenInteractive(
172219
User user,
173220
PublicClientApplication pca,

src/integrationtest/java/com.microsoft.aad.msal4j/OAuthRequestValidationUnitT.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
import org.testng.Assert;
88
import org.testng.annotations.Test;
99

10-
import java.util.Collections;
11-
import java.util.Map;
10+
import java.util.*;
1211
import java.util.concurrent.ExecutionException;
1312

1413
public class OAuthRequestValidationUnitT extends OAuthRequestValidationTest {
@@ -41,8 +40,16 @@ public void oAuthRequest_for_acquireTokenByClientCertificate() throws Exception
4140
// validate Client Authentication query params
4241
Assert.assertFalse(StringUtils.isEmpty(queryParams.get("client_assertion")));
4342

44-
// to do validate scopes
45-
Assert.assertEquals(SCOPES, queryParams.get("scope"));
43+
Set<String> scopes = new HashSet<>(
44+
Arrays.asList(queryParams.get("scope").split(AbstractMsalAuthorizationGrant.SCOPES_DELIMITER)));
45+
46+
// validate custom scopes
47+
Assert.assertTrue(scopes.contains(SCOPES));
48+
49+
// validate common scopes
50+
Assert.assertTrue(scopes.contains(AbstractMsalAuthorizationGrant.SCOPE_OPEN_ID));
51+
Assert.assertTrue(scopes.contains(AbstractMsalAuthorizationGrant.SCOPE_PROFILE));
52+
Assert.assertTrue(scopes.contains(AbstractMsalAuthorizationGrant.SCOPE_OFFLINE_ACCESS));
4653

4754
Assert.assertEquals(CLIENT_ASSERTION_TYPE_JWT, queryParams.get("client_assertion_type"));
4855
Assert.assertEquals(ON_BEHALF_OF_USE_JWT, queryParams.get("requested_token_use"));
@@ -86,7 +93,7 @@ public void oAuthRequest_for_acquireTokenByClientAssertion() throws Exception {
8693
Assert.assertEquals(CLIENT_ASSERTION_TYPE_JWT, queryParams.get("client_assertion_type"));
8794

8895
// to do validate scopes
89-
Assert.assertEquals("openid profile offline_access https://SomeResource.azure.net", queryParams.get("scope"));
96+
Assert.assertEquals("https://SomeResource.azure.net openid profile offline_access", queryParams.get("scope"));
9097

9198
Assert.assertEquals(CLIENT_INFO_VALUE, queryParams.get("client_info"));
9299
}

src/integrationtest/java/com.microsoft.aad.msal4j/TestConstants.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,9 @@ public class TestConstants {
5050
public final static String CLAIMS = "{\"id_token\":{\"auth_time\":{\"essential\":true}}}";
5151
public final static Set<String> CLIENT_CAPABILITIES_EMPTY = new HashSet<String>(Collections.emptySet());
5252
public final static Set<String> CLIENT_CAPABILITIES_LLT = new HashSet<String>(Collections.singletonList("llt"));
53+
54+
// cross cloud b2b settings
55+
public final static String AUTHORITY_ARLINGTON = "https://login.microsoftonline.us/arlmsidlab1.onmicrosoft.us";
56+
public final static String AUTHORITY_MOONCAKE = "https://login.chinacloudapi.cn/mncmsidlab1.partner.onmschina.cn";
57+
public final static String AUTHORITY_PUBLIC_TENANT_SPECIFIC = "https://login.microsoftonline.com/msidlab4.onmicrosoft.com";
5358
}

src/integrationtest/java/infrastructure/SeleniumConstants.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,11 @@ public class SeleniumConstants {
4747
final static String B2C_LOCAL_USERNAME_ID = "cred_userid_inputtext";
4848
final static String B2C_LOCAL_PASSWORD_ID = "cred_password_inputtext";
4949
final static String B2C_LOCAL_SIGN_IN_BUTTON_ID = "cred_sign_in_button";
50+
51+
// Stay signed in?
52+
final static String STAY_SIGN_IN_NO_BUTTON_ID = "idBtn_Back";
53+
54+
// Are you trying to sign in to ...
55+
//Only continue if you downloaded the app from a store or website that you trust.
56+
final static String ARE_YOU_TRYING_TO_SIGN_IN_TO = "idSIButton9";
5057
}

src/integrationtest/java/infrastructure/SeleniumExtensions.java

Lines changed: 48 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
package infrastructure;
55

6-
import com.microsoft.aad.msal4j.TestConstants;
76
import labapi.FederationProvider;
87
import labapi.LabConstants;
98
import labapi.User;
@@ -12,10 +11,12 @@
1211
import org.openqa.selenium.OutputType;
1312
import org.openqa.selenium.StaleElementReferenceException;
1413
import org.openqa.selenium.TakesScreenshot;
14+
import org.openqa.selenium.TimeoutException;
1515
import org.openqa.selenium.WebDriver;
1616
import org.openqa.selenium.WebElement;
1717
import org.openqa.selenium.chrome.ChromeDriver;
1818
import org.openqa.selenium.chrome.ChromeOptions;
19+
import org.openqa.selenium.support.ui.ExpectedCondition;
1920
import org.openqa.selenium.support.ui.WebDriverWait;
2021
import org.slf4j.Logger;
2122
import org.slf4j.LoggerFactory;
@@ -41,8 +42,8 @@ public static WebDriver createDefaultWebDriver(){
4142
return driver;
4243
}
4344

44-
public static WebElement waitForElementToBeVisibleAndEnable(WebDriver driver, By by){
45-
WebDriverWait webDriverWait = new WebDriverWait(driver, 15);
45+
public static WebElement waitForElementToBeVisibleAndEnable(WebDriver driver, By by, int timeOutInSeconds) {
46+
WebDriverWait webDriverWait = new WebDriverWait(driver, timeOutInSeconds);
4647
return webDriverWait.until((dr) ->
4748
{
4849
try {
@@ -52,11 +53,17 @@ public static WebElement waitForElementToBeVisibleAndEnable(WebDriver driver, By
5253
}
5354
return null;
5455
} catch (StaleElementReferenceException e) {
55-
return null;
56+
return null;
5657
}
5758
});
5859
}
5960

61+
public static WebElement waitForElementToBeVisibleAndEnable(WebDriver driver, By by){
62+
int DEFAULT_TIMEOUT_IN_SEC = 15;
63+
64+
return waitForElementToBeVisibleAndEnable(driver, by, DEFAULT_TIMEOUT_IN_SEC);
65+
}
66+
6067
public static void performADLogin(WebDriver driver, User user){
6168
LOG.info("PerformADLogin");
6269

@@ -81,8 +88,44 @@ public static void performADLogin(WebDriver driver, User user){
8188
waitForElementToBeVisibleAndEnable(driver, by).sendKeys(user.getPassword());
8289

8390
LOG.info("Loggin in ... click submit");
84-
waitForElementToBeVisibleAndEnable(driver, new By.ById(fields.getPasswordSigInButtonId())).
91+
waitForElementToBeVisibleAndEnable(driver, new By.ById(fields.getPasswordSigInButtonId())).
8592
click();
93+
94+
try {
95+
checkAuthenticationCompletePage(driver);
96+
return;
97+
} catch (TimeoutException ex) {
98+
}
99+
100+
LOG.info("Checking optional questions");
101+
102+
try {
103+
LOG.info("Are you trying to sign in to ... ? checking");
104+
waitForElementToBeVisibleAndEnable(driver, new By.ById(SeleniumConstants.ARE_YOU_TRYING_TO_SIGN_IN_TO), 3).
105+
click();
106+
LOG.info("Are you trying to sign in to ... ? click Continue");
107+
108+
} catch (TimeoutException ex) {
109+
}
110+
111+
try {
112+
LOG.info("Stay signed in? checking");
113+
waitForElementToBeVisibleAndEnable(driver, new By.ById(SeleniumConstants.STAY_SIGN_IN_NO_BUTTON_ID), 3).
114+
click();
115+
LOG.info("Stay signed in? click NO");
116+
} catch (TimeoutException ex) {
117+
}
118+
}
119+
120+
private static void checkAuthenticationCompletePage(WebDriver driver) {
121+
(new WebDriverWait(driver, 5)).until((ExpectedCondition<Boolean>) d -> {
122+
boolean condition = false;
123+
WebElement we = d.findElement(new By.ByTagName("body"));
124+
if (we != null && we.getText().contains("Authentication complete")) {
125+
condition = true;
126+
}
127+
return condition;
128+
});
86129
}
87130

88131
public static void performADFS2019Login(WebDriver driver, User user){

src/integrationtest/java/labapi/LabConstants.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,6 @@ public class LabConstants {
2121
public final static String MSA_APP_ID = "9668f2bd-6103-4292-9024-84fa2d1b6fb2";
2222

2323
public final static String ARLINGTON_LAB_NAME = "ARLMSIDLAB1";
24+
public final static String GUEST_USER_TYPE = "Guest";
25+
2426
}

src/integrationtest/java/labapi/LabService.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,13 @@ User getUser(UserQueryParameters query){
5959

6060
User[] users = convertJsonToObject(result, User[].class);
6161
User user = users[0];
62-
user.setPassword(getSecret(user.getLabName()));
62+
if(user.getUserType().equals("Guest")){
63+
String secretId = user.getHomeDomain().split("\\.")[0];
64+
user.setPassword(getSecret(secretId));
65+
}
66+
else {
67+
user.setPassword(getSecret(user.getLabName()));
68+
}
6369
if (query.parameters.containsKey(UserQueryParameters.FEDERATION_PROVIDER)) {
6470
user.setFederationProvider(query.parameters.get(UserQueryParameters.FEDERATION_PROVIDER));
6571
} else {

src/integrationtest/java/labapi/LabUserProvider.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,18 @@ public User getUserByAzureEnvironment(String azureEnvironment) {
8686
return getLabUser(query);
8787
}
8888

89+
public User getUserByGuestHomeAzureEnvironments(String guestEnvironment, String homeEnvironment) {
90+
91+
UserQueryParameters query = new UserQueryParameters();
92+
query.parameters.put(UserQueryParameters.USER_TYPE, "guest");
93+
query.parameters.put(UserQueryParameters.AZURE_ENVIRONMENT, guestEnvironment);
94+
query.parameters.put(UserQueryParameters.HOME_AZURE_ENVIRONMENT, homeEnvironment);
95+
query.parameters.put(UserQueryParameters.GUEST_HOME_DIN, "hostazuread");
96+
query.parameters.put(UserQueryParameters.SIGN_IN_AUDIENCE, "azureadmyorg");
97+
98+
return getLabUser(query);
99+
}
100+
89101
public User getLabUser(UserQueryParameters userQuery){
90102
if(userCache.containsKey(userQuery)){
91103
return userCache.get(userQuery);

src/integrationtest/java/labapi/User.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public class User
2626
private String licenses;
2727

2828
@JsonProperty("upn")
29+
@Setter
2930
private String upn;
3031

3132
@JsonProperty("mfa")

src/integrationtest/java/labapi/UserQueryParameters.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ public class UserQueryParameters {
1919
public static final String B2C_PROVIDER = "b2cprovider";
2020
public static final String FEDERATION_PROVIDER = "federationprovider";
2121
public static final String AZURE_ENVIRONMENT = "azureenvironment";
22-
public static final String SIGN_IN_AUDIENCE = "signinaudience";
22+
public static final String HOME_AZURE_ENVIRONMENT = "guesthomeazureenvironment";
23+
public static final String GUEST_HOME_DIN = "guesthomedin";
24+
public static final String SIGN_IN_AUDIENCE = "signInAudience";
2325

2426
public Map<String, String> parameters = new HashMap<>();
2527
}

0 commit comments

Comments
 (0)