Skip to content

Release 1.11.0 #420

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 43 commits into from
Jul 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
67e5567
Pesomka/b2b stage1 (#356)
SomkaPe Mar 5, 2021
eb59cba
Pesomka/key store provider (#358)
SomkaPe Apr 2, 2021
84729c0
Instance aware support (#362)
Avery-Dunn Apr 2, 2021
b873c9f
Update telemetry to reduce size of payload (#361)
sangonzal Apr 2, 2021
68033f8
Bump guava from 26.0-jre to 29.0-jre (#366)
dependabot[bot] Apr 2, 2021
ed11410
Bump guava from 26.0-jre to 29.0-jre in /src/samples/msal-obo-sample …
dependabot[bot] Apr 2, 2021
5118f9d
survey added to README.md
Apr 6, 2021
efdadc0
Merge pull request #369 from ShannonCanTech/loyalty-survey-readme
sangonzal Apr 8, 2021
af88e0b
Update oauth2-oidc-sdk dependency (#373)
Avery-Dunn Apr 26, 2021
6198e90
Add default cache lookup to client credential flow (#368)
sangonzal Apr 26, 2021
287365c
Bump commons-io from 2.6 to 2.7 (#376)
dependabot[bot] Apr 26, 2021
a5e070a
Sagonzal/update client credentials (#377)
SomkaPe Apr 26, 2021
1c89680
1.10.0 release
SomkaPe Apr 26, 2021
0f3574d
fix for issue with common scopes override (#385)
SomkaPe May 11, 2021
44d56a7
Add ccs routing headers. Add option to pass in header map
May 11, 2021
204f90e
Rename IApiParameters to IAcquireTokenParameters
May 11, 2021
dc9a328
PR Feedback
May 18, 2021
37cfd55
Add CCS routing information to /authorize query parameters
May 18, 2021
63671f5
Update log levels for operations in OBO and ClientCredential supliers
May 19, 2021
d0c4e29
Merge pull request #392 from AzureAD/sagonzal/update-log-levels
sangonzal May 27, 2021
dbc71be
Update how non 200 http response are handled. Update to only throw Ms…
May 27, 2021
7b71c7c
Update unit tests
May 27, 2021
cdff1cb
Merge pull request #387 from AzureAD/sagonzal/ccs-routing
sangonzal May 28, 2021
ffd7ef4
Merge branch 'dev' into sagonzal/improve-exceptions
Jun 1, 2021
dc46e97
Retrigger build
Jun 2, 2021
2ec7d9c
Update unit test
Jun 2, 2021
29423b4
Merge pull request #397 from AzureAD/sagonzal/improve-exceptions
sangonzal Jun 2, 2021
b4b13b5
Bump httpclient from 4.5.9 to 4.5.13 (#401)
dependabot[bot] Jun 4, 2021
01bb679
Improve region support and add region telemetry (#388)
Avery-Dunn Jun 8, 2021
5f70b27
integration test for cross cloud b2b (#396)
SomkaPe Jun 16, 2021
16ad557
Version and changelog updates for release 1.10.1 (#405)
Avery-Dunn Jun 16, 2021
1a89151
Merge branch 'main' into dev
Avery-Dunn Jun 16, 2021
e6a10f4
Fix merge conflicts
Avery-Dunn Jun 16, 2021
4637df0
Use host parameter instead of authority
MSSedusch Jun 25, 2021
40ffaf8
Fix sonar warnings.
Vaisman Jul 6, 2021
8823af4
Add port to authority. Add test
Jul 7, 2021
cc01026
Merge pull request #410 from Vaisman/fix-sonar-warnings
sangonzal Jul 9, 2021
6c68a2e
Add port to instance discovery url
Jul 12, 2021
2cffa38
Merge pull request #409 from MSSedusch/dev
sangonzal Jul 13, 2021
17474df
Allow tenant to be overridden when requesting tokens (#412)
Avery-Dunn Jul 15, 2021
5fa1881
Bump version and update changelog for release v1.11.0
Jul 16, 2021
8fc2b45
Merge pull request #419 from AzureAD/sagonzal/release1.11.0
sangonzal Jul 16, 2021
3e42121
Merge branch 'main' into dev
sangonzal Jul 16, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,6 @@

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

# Lombok
target/*
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Quick links:
The library supports the following Java environments:
- Java 8 (or higher)

Current version - 1.10.1
Current version - 1.11.0

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).

Expand All @@ -28,13 +28,13 @@ Find [the latest package in the Maven repository](https://mvnrepository.com/arti
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>msal4j</artifactId>
<version>1.10.1</version>
<version>1.11.0</version>
</dependency>
```
### Gradle

```
compile group: 'com.microsoft.azure', name: 'msal4j', version: '1.10.1'
compile group: 'com.microsoft.azure', name: 'msal4j', version: '1.11.0'
```

## Usage
Expand Down
5 changes: 5 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
Version 1.11.0
=============
- Adds ability to override authority in AcquireToken calls
- Fixes issue where authority port was being dropped from URLs

Version 1.10.1
=============
- Improved behavior when using regional authorities
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.microsoft.azure</groupId>
<artifactId>msal4j</artifactId>
<version>1.10.1</version>
<version>1.11.0</version>
<packaging>jar</packaging>
<name>msal4j</name>
<description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public void acquireTokenSilent_ForceRefresh(String environment) throws Exception
assertResultNotNull(resultAfterRefresh);

// Check that new refresh and id tokens are being returned
assertResultRefreshed(result, resultAfterRefresh);
assertTokensAreNotEqual(result, resultAfterRefresh);
}

@Test(dataProvider = "environments", dataProviderClass = EnvironmentsProvider.class)
Expand Down Expand Up @@ -135,7 +135,7 @@ public void acquireTokenSilent_ADFS2019(String environment) throws Exception{
IAuthenticationResult resultAfterRefresh = acquireTokenSilently(pca, account, TestConstants.ADFS_SCOPE, true);
assertResultNotNull(resultAfterRefresh);

assertResultRefreshed(result, resultAfterRefresh);
assertTokensAreNotEqual(result, resultAfterRefresh);
}

// Commented out due to unclear B2C behavior causing occasional errors
Expand All @@ -158,7 +158,7 @@ public void acquireTokenSilent_B2C() throws Exception{
IAuthenticationResult resultAfterRefresh = acquireTokenSilently(pca, account, TestConstants.B2C_READ_SCOPE, true);
assertResultNotNull(resultAfterRefresh);

assertResultRefreshed(result, resultAfterRefresh);
assertTokensAreNotEqual(result, resultAfterRefresh);
}


Expand Down Expand Up @@ -261,7 +261,38 @@ public void acquireTokenSilent_WithRefreshOn(String environment) throws Exceptio
resultSilentWithRefreshOn = acquireTokenSilently(pca, resultOriginal.account(), cfg.graphDefaultScope(), false);
//Current time is after refreshOn, so token should be refreshed
Assert.assertNotNull(resultSilentWithRefreshOn);
assertResultRefreshed(resultSilent, resultSilentWithRefreshOn);
assertTokensAreNotEqual(resultSilent, resultSilentWithRefreshOn);
}

@Test(dataProvider = "environments", dataProviderClass = EnvironmentsProvider.class)
public void acquireTokenSilent_TenantAsParameter(String environment) throws Exception {
cfg = new Config(environment);

User user = labUserProvider.getDefaultUser(environment);

PublicClientApplication pca = PublicClientApplication.builder(
user.getAppId()).
authority(cfg.organizationsAuthority()).
build();

IAuthenticationResult result = pca.acquireToken(UserNamePasswordParameters.
builder(Collections.singleton(cfg.graphDefaultScope()),
user.getUpn(),
user.getPassword().toCharArray())
.build()).get();
assertResultNotNull(result);

IAccount account = pca.getAccounts().join().iterator().next();
IAuthenticationResult silentResult = acquireTokenSilently(pca, account, cfg.graphDefaultScope(), false);
assertResultNotNull(silentResult);
assertTokensAreEqual(result, silentResult);

IAuthenticationResult resultWithTenantParam = pca.acquireTokenSilently(SilentParameters.
builder(Collections.singleton(cfg.graphDefaultScope()), account).
tenant(cfg.tenant()).
build()).get();
assertResultNotNull(resultWithTenantParam);
assertTokensAreNotEqual(result, resultWithTenantParam);
}

private IConfidentialClientApplication getConfidentialClientApplications() throws Exception{
Expand Down Expand Up @@ -335,13 +366,13 @@ private void assertResultNotNull(IAuthenticationResult result) {
Assert.assertNotNull(result.idToken());
}

private void assertResultRefreshed(IAuthenticationResult result, IAuthenticationResult resultAfterRefresh) {
Assert.assertNotEquals(result.accessToken(), resultAfterRefresh.accessToken());
Assert.assertNotEquals(result.idToken(), resultAfterRefresh.idToken());
private void assertTokensAreNotEqual(IAuthenticationResult result, IAuthenticationResult secondResult) {
Assert.assertNotEquals(result.accessToken(), secondResult.accessToken());
Assert.assertNotEquals(result.idToken(), secondResult.idToken());
}

private void assertTokensAreEqual(IAuthenticationResult result, IAuthenticationResult resultAfterRefresh) {
Assert.assertEquals(result.accessToken(), resultAfterRefresh.accessToken());
Assert.assertEquals(result.idToken(), resultAfterRefresh.idToken());
private void assertTokensAreEqual(IAuthenticationResult result, IAuthenticationResult secondResult) {
Assert.assertEquals(result.accessToken(), secondResult.accessToken());
Assert.assertEquals(result.idToken(), secondResult.idToken());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

class ApacheHttpClientAdapter implements IHttpClient {

private CloseableHttpClient httpClient;
private final CloseableHttpClient httpClient;

ApacheHttpClientAdapter(){
this.httpClient = HttpClients.createDefault();
Expand Down
3 changes: 3 additions & 0 deletions src/integrationtest/java/com.microsoft.aad.msal4j/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class Config {
private String tenantSpecificAuthority;
private String graphDefaultScope;
AppCredentialProvider appProvider;
private String tenant;

String azureEnvironment;

Expand All @@ -27,12 +28,14 @@ public class Config {
tenantSpecificAuthority = TestConstants.TENANT_SPECIFIC_AUTHORITY;
graphDefaultScope = TestConstants.GRAPH_DEFAULT_SCOPE;
appProvider = new AppCredentialProvider(azureEnvironment);
tenant = TestConstants.MICROSOFT_AUTHORITY_TENANT;
break;
case AzureEnvironment.AZURE_US_GOVERNMENT :
organizationsAuthority = TestConstants.ARLINGTON_ORGANIZATIONS_AUTHORITY;
tenantSpecificAuthority = TestConstants.ARLINGTON_TENANT_SPECIFIC_AUTHORITY;
graphDefaultScope = TestConstants.ARLINGTON_GRAPH_DEFAULT_SCOPE;
appProvider = new AppCredentialProvider(azureEnvironment);
tenant = TestConstants.ARLINGTON_AUTHORITY_TENANT;
break;
default:
throw new UnsupportedOperationException("Azure Environment - " + azureEnvironment + " unsupported");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ public class DeviceCodeIT {
private LabUserProvider labUserProvider;
private WebDriver seleniumDriver;

private Config cfg;

@BeforeClass
public void setUp(){
labUserProvider = LabUserProvider.getInstance();
Expand All @@ -36,7 +34,7 @@ public void setUp(){

@Test(dataProvider = "environments", dataProviderClass = EnvironmentsProvider.class)
public void DeviceCodeFlowADTest(String environment) throws Exception {
cfg = new Config(environment);
Config cfg = new Config(environment);

User user = labUserProvider.getDefaultUser(cfg.azureEnvironment);

Expand All @@ -56,7 +54,7 @@ public void DeviceCodeFlowADTest(String environment) throws Exception {
.get();

Assert.assertNotNull(result);
Assert.assertTrue(!Strings.isNullOrEmpty(result.accessToken()));
Assert.assertFalse(Strings.isNullOrEmpty(result.accessToken()));
}

@Test(dataProvider = "environments", dataProviderClass = EnvironmentsProvider.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
package com.microsoft.aad.msal4j;

import labapi.LabUserProvider;
import labapi.AzureEnvironment;
import labapi.User;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ public void oAuthRequest_for_acquireTokenByClientCertificate() throws Exception
}

Map<String, String> queryParams = splitQuery(query);
Assert.assertEquals(7, queryParams.size());
Assert.assertEquals(queryParams.size(), 7);

// validate Authorization Grants query params
Assert.assertEquals(GRANT_TYPE_JWT, queryParams.get("grant_type"));
Assert.assertEquals(JWT, queryParams.get("assertion"));
Assert.assertEquals(queryParams.get("grant_type"), GRANT_TYPE_JWT);
Assert.assertEquals(queryParams.get("assertion"), JWT);

// validate Client Authentication query params
Assert.assertFalse(StringUtils.isEmpty(queryParams.get("client_assertion")));
Expand All @@ -51,10 +51,10 @@ public void oAuthRequest_for_acquireTokenByClientCertificate() throws Exception
Assert.assertTrue(scopes.contains(AbstractMsalAuthorizationGrant.SCOPE_PROFILE));
Assert.assertTrue(scopes.contains(AbstractMsalAuthorizationGrant.SCOPE_OFFLINE_ACCESS));

Assert.assertEquals(CLIENT_ASSERTION_TYPE_JWT, queryParams.get("client_assertion_type"));
Assert.assertEquals(ON_BEHALF_OF_USE_JWT, queryParams.get("requested_token_use"));
Assert.assertEquals(queryParams.get("client_assertion_type"), CLIENT_ASSERTION_TYPE_JWT);
Assert.assertEquals(queryParams.get("requested_token_use"), ON_BEHALF_OF_USE_JWT);

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

@Test
Expand Down Expand Up @@ -83,18 +83,18 @@ public void oAuthRequest_for_acquireTokenByClientAssertion() throws Exception {

Map<String, String> queryParams = splitQuery(query);

Assert.assertEquals(5, queryParams.size());
Assert.assertEquals(queryParams.size(), 5);

// validate Authorization Grants query params
Assert.assertEquals(CLIENT_CREDENTIALS_GRANT_TYPE, queryParams.get("grant_type"));
Assert.assertEquals(queryParams.get("grant_type"), CLIENT_CREDENTIALS_GRANT_TYPE);

// validate Client Authentication query params
Assert.assertTrue(StringUtils.isNotEmpty(queryParams.get("client_assertion")));
Assert.assertEquals(CLIENT_ASSERTION_TYPE_JWT, queryParams.get("client_assertion_type"));
Assert.assertEquals(queryParams.get("client_assertion_type"), CLIENT_ASSERTION_TYPE_JWT);

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

Assert.assertEquals(CLIENT_INFO_VALUE, queryParams.get("client_info"));
Assert.assertEquals(queryParams.get("client_info"), CLIENT_INFO_VALUE);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

class OkHttpClientAdapter implements IHttpClient{

private OkHttpClient client;
private final OkHttpClient client;

OkHttpClientAdapter(){
this.client = new OkHttpClient();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@
package com.microsoft.aad.msal4j;

import labapi.LabUserProvider;
import labapi.AzureEnvironment;
import labapi.User;
import org.testng.Assert;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;

import java.util.Collections;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,20 @@ public class TestConstants {
public final static String B2C_CONFIDENTIAL_CLIENT_LAB_APP_ID = "MSIDLABB2C-MSAapp-AppID";

public final static String MICROSOFT_AUTHORITY_HOST = "https://login.microsoftonline.com/";
public final static String MICROSOFT_AUTHORITY_HOST_WITH_PORT = "https://login.microsoftonline.com:443/";
public final static String ARLINGTON_MICROSOFT_AUTHORITY_HOST = "https://login.microsoftonline.us/";
public final static String MICROSOFT_AUTHORITY_TENANT = "msidlab4.onmicrosoft.com";
public final static String ARLINGTON_AUTHORITY_TENANT = "arlmsidlab1.onmicrosoft.us";

public final static String ORGANIZATIONS_AUTHORITY = MICROSOFT_AUTHORITY_HOST + "organizations/";
public final static String COMMON_AUTHORITY = MICROSOFT_AUTHORITY_HOST + "common/";
public final static String COMMON_AUTHORITY_WITH_PORT = MICROSOFT_AUTHORITY_HOST_WITH_PORT + "msidlab4.onmicrosoft.com";
public final static String MICROSOFT_AUTHORITY = MICROSOFT_AUTHORITY_HOST + "microsoft.onmicrosoft.com";
public final static String TENANT_SPECIFIC_AUTHORITY = MICROSOFT_AUTHORITY_HOST + "msidlab4.onmicrosoft.com";
public final static String TENANT_SPECIFIC_AUTHORITY = MICROSOFT_AUTHORITY_HOST + MICROSOFT_AUTHORITY_TENANT;

public final static String ARLINGTON_ORGANIZATIONS_AUTHORITY = ARLINGTON_MICROSOFT_AUTHORITY_HOST + "organizations/";
public final static String ARLINGTON_COMMON_AUTHORITY = ARLINGTON_MICROSOFT_AUTHORITY_HOST + "common/";
public final static String ARLINGTON_TENANT_SPECIFIC_AUTHORITY = ARLINGTON_MICROSOFT_AUTHORITY_HOST + "arlmsidlab1.onmicrosoft.us";
public final static String ARLINGTON_TENANT_SPECIFIC_AUTHORITY = ARLINGTON_MICROSOFT_AUTHORITY_HOST + ARLINGTON_AUTHORITY_TENANT;
public final static String ARLINGTON_GRAPH_DEFAULT_SCOPE = "https://graph.microsoft.us/.default";


Expand All @@ -48,11 +52,11 @@ public class TestConstants {
public final static String ADFS_APP_ID = "PublicClientId";

public final static String CLAIMS = "{\"id_token\":{\"auth_time\":{\"essential\":true}}}";
public final static Set<String> CLIENT_CAPABILITIES_EMPTY = new HashSet<String>(Collections.emptySet());
public final static Set<String> CLIENT_CAPABILITIES_LLT = new HashSet<String>(Collections.singletonList("llt"));
public final static Set<String> CLIENT_CAPABILITIES_EMPTY = new HashSet<>(Collections.emptySet());
public final static Set<String> CLIENT_CAPABILITIES_LLT = new HashSet<>(Collections.singletonList("llt"));

// cross cloud b2b settings
public final static String AUTHORITY_ARLINGTON = "https://login.microsoftonline.us/arlmsidlab1.onmicrosoft.us";
public final static String AUTHORITY_ARLINGTON = "https://login.microsoftonline.us/" + ARLINGTON_AUTHORITY_TENANT;
public final static String AUTHORITY_MOONCAKE = "https://login.chinacloudapi.cn/mncmsidlab1.partner.onmschina.cn";
public final static String AUTHORITY_PUBLIC_TENANT_SPECIFIC = "https://login.microsoftonline.com/msidlab4.onmicrosoft.com";
public final static String AUTHORITY_PUBLIC_TENANT_SPECIFIC = "https://login.microsoftonline.com/" + MICROSOFT_AUTHORITY_TENANT;
}
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,17 @@ public void acquireTokenWithUsernamePassword_ADFSv2(String environment) throws E
assertAcquireTokenCommonAAD(user);
}

@Test
public void acquireTokenWithUsernamePassword_AuthorityWithPort() throws Exception {
User user = labUserProvider.getDefaultUser();

assertAcquireTokenCommon(
user,
TestConstants.COMMON_AUTHORITY_WITH_PORT,
TestConstants.GRAPH_DEFAULT_SCOPE,
user.getAppId());
}

private void assertAcquireTokenCommonADFS(User user) throws Exception {
assertAcquireTokenCommon(user, TestConstants.ADFS_AUTHORITY, TestConstants.ADFS_SCOPE,
TestConstants.ADFS_APP_ID);
Expand Down
10 changes: 5 additions & 5 deletions src/integrationtest/java/labapi/KeyVaultSecretsProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@

public class KeyVaultSecretsProvider {

private KeyVaultClient keyVaultClient;
private static String CLIENT_ID = "55e7e5af-ca53-482d-9aa3-5cb1cc8eecb5";
private final KeyVaultClient keyVaultClient;
private static final String CLIENT_ID = "55e7e5af-ca53-482d-9aa3-5cb1cc8eecb5";
public static String CERTIFICATE_ALIAS = "MsalJavaAutomationRunner";

private static String WIN_KEYSTORE = "Windows-MY";
private static String KEYSTORE_PROVIDER = "SunMSCAPI";
private static final String WIN_KEYSTORE = "Windows-MY";
private static final String KEYSTORE_PROVIDER = "SunMSCAPI";

private static String MAC_KEYSTORE = "KeychainStore";
private static final String MAC_KEYSTORE = "KeychainStore";

KeyVaultSecretsProvider(){
keyVaultClient = getAuthenticatedKeyVaultClient();
Expand Down
Loading