Skip to content

Commit 90a2d9a

Browse files
authored
Update regional endpoints (#504)
* Minor fixes/enhancements * Update regional endpoint formatting
1 parent 3fc0148 commit 90a2d9a

File tree

4 files changed

+31
-13
lines changed

4 files changed

+31
-13
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
--------------------|-----------------|---------------
55
[![Build status](https://identitydivision.visualstudio.com/IDDP/_apis/build/status/CI/Java/MSAL%20Java%20CI%20Build?branchName=main)](https://identitydivision.visualstudio.com/IDDP/_build/latest?definitionId=762) | [![Build status](https://identitydivision.visualstudio.com/IDDP/_apis/build/status/CI/Java/MSAL%20Java%20CI%20Build?branchName=dev)](https://identitydivision.visualstudio.com/IDDP/_build/latest?definitionId=762)| [![Javadocs](http://javadoc.io/badge/com.microsoft.azure/msal4j.svg)](http://javadoc.io/doc/com.microsoft.azure/msal4j)
66

7-
The Microsoft Authentication Library for Java (MSAL4J) enables applications to integrate with the [Microsoft identity platform](https://aka.ms/aaddevv2). It allows you to sign in users or apps with Microsoft identities (Azure AD, Microsoft accounts and Azure AD B2C accounts) and obtain tokens to call Microsoft APIs such as [Microsoft Graph](https://graph.microsoft.io/) or your own APIs registered with the Microsoft identity platform. It is built using industry standard OAuth2 and OpenID Connect protocols.
7+
The Microsoft Authentication Library for Java (MSAL4J) enables applications to integrate with the [Microsoft identity platform](https://docs.microsoft.com/en-us/azure/active-directory/develop/). It allows you to sign in users or apps with Microsoft identities (Azure AD, Microsoft accounts and Azure AD B2C accounts) and obtain tokens to call Microsoft APIs such as [Microsoft Graph](https://graph.microsoft.io/) or your own APIs registered with the Microsoft identity platform. It is built using industry standard OAuth2 and OpenID Connect protocols.
88

99
Quick links:
1010

@@ -58,7 +58,7 @@ This project has adopted the Microsoft Open Source Code of Conduct. For more inf
5858

5959
## Samples and Documentation
6060

61-
We provide a [full suite of sample applications](https://aka.ms/aaddevsamplesv2) and [documentation](https://aka.ms/aaddevv2) to help you get started with learning the Microsoft identity platform.
61+
We provide a [full suite of sample applications](https://aka.ms/aaddevsamplesv2) and [documentation](https://docs.microsoft.com/en-us/azure/active-directory/develop/) to help you get started with learning the Microsoft identity platform.
6262

6363
## Community Help and Support
6464

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

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ class AadInstanceDiscoveryProvider {
2222
private final static String DEFAULT_TRUSTED_HOST = "login.microsoftonline.com";
2323
private final static String AUTHORIZE_ENDPOINT_TEMPLATE = "https://{host}/{tenant}/oauth2/v2.0/authorize";
2424
private final static String INSTANCE_DISCOVERY_ENDPOINT_TEMPLATE = "https://{host}:{port}/common/discovery/instance";
25-
private final static String INSTANCE_DISCOVERY_ENDPOINT_TEMPLATE_WITH_REGION = "https://{region}.{host}:{port}/common/discovery/instance";
25+
private final static String INSTANCE_DISCOVERY_ENDPOINT_TEMPLATE_WITH_REGION = "https://{region}.r.{host}:{port}/common/discovery/instance";
26+
private final static String INSTANCE_DISCOVERY_SOVEREIGN_ENDPOINT_TEMPLATE_WITH_REGION = "https://{region}.{host}:{port}/common/discovery/instance";
2627
private final static String INSTANCE_DISCOVERY_REQUEST_PARAMETERS_TEMPLATE = "?api-version=1.1&authorization_endpoint={authorizeEndpoint}";
2728
private final static String REGION_NAME = "REGION_NAME";
2829
private final static int PORT_NOT_SET = -1;
@@ -31,19 +32,24 @@ class AadInstanceDiscoveryProvider {
3132
private final static String IMDS_ENDPOINT = "https://169.254.169.254/metadata/instance/compute/location?" + DEFAULT_API_VERSION + "&format=text";
3233

3334
final static TreeSet<String> TRUSTED_HOSTS_SET = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
35+
final static TreeSet<String> TRUSTED_SOVEREIGN_HOSTS_SET = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
3436

3537
private final static Logger log = LoggerFactory.getLogger(HttpHelper.class);
3638

3739
static ConcurrentHashMap<String, InstanceDiscoveryMetadataEntry> cache = new ConcurrentHashMap<>();
3840

3941
static {
40-
TRUSTED_HOSTS_SET.addAll(Arrays.asList(
41-
"login.windows.net",
42+
TRUSTED_SOVEREIGN_HOSTS_SET.addAll(Arrays.asList(
4243
"login.chinacloudapi.cn",
4344
"login-us.microsoftonline.com",
4445
"login.microsoftonline.de",
45-
"login.microsoftonline.com",
4646
"login.microsoftonline.us"));
47+
48+
TRUSTED_HOSTS_SET.addAll(Arrays.asList(
49+
"login.windows.net",
50+
"login.microsoftonline.com"));
51+
52+
TRUSTED_HOSTS_SET.addAll(TRUSTED_SOVEREIGN_HOSTS_SET);
4753
}
4854

4955
static InstanceDiscoveryMetadataEntry getMetadataEntry(URL authorityUrl,
@@ -133,10 +139,17 @@ private static String getInstanceDiscoveryEndpointWithRegion(URL authorityUrl, S
133139
authorityUrl.getDefaultPort() :
134140
authorityUrl.getPort();
135141

136-
return INSTANCE_DISCOVERY_ENDPOINT_TEMPLATE_WITH_REGION.
137-
replace("{region}", region).
138-
replace("{host}", discoveryHost).
139-
replace("{port}", String.valueOf(port));
142+
if (TRUSTED_SOVEREIGN_HOSTS_SET.contains(authorityUrl.getHost())) {
143+
return INSTANCE_DISCOVERY_SOVEREIGN_ENDPOINT_TEMPLATE_WITH_REGION.
144+
replace("{region}", region).
145+
replace("{host}", discoveryHost).
146+
replace("{port}", String.valueOf(port));
147+
} else {
148+
return INSTANCE_DISCOVERY_ENDPOINT_TEMPLATE_WITH_REGION.
149+
replace("{region}", region).
150+
replace("{host}", discoveryHost).
151+
replace("{port}", String.valueOf(port));
152+
}
140153
}
141154

142155

src/main/java/com/microsoft/aad/msal4j/AbstractClientApplicationBase.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
* Abstract class containing common methods and properties to both {@link PublicClientApplication}
2929
* and {@link ConfidentialClientApplication}.
3030
*/
31-
abstract class AbstractClientApplicationBase implements IClientApplicationBase {
31+
public abstract class AbstractClientApplicationBase implements IClientApplicationBase {
3232

3333
protected Logger log;
3434
protected Authority authenticationAuthority;
@@ -300,7 +300,7 @@ ServiceBundle getServiceBundle() {
300300
return serviceBundle;
301301
}
302302

303-
abstract static class Builder<T extends Builder<T>> {
303+
public abstract static class Builder<T extends Builder<T>> {
304304
// Required parameters
305305
private String clientId;
306306

src/main/java/com/microsoft/aad/msal4j/Prompt.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,12 @@ public enum Prompt {
3636
/**
3737
* An administrator should be prompted to consent on behalf of all users in their organization.
3838
*/
39-
ADMIN_CONSENT("admin_consent");
39+
ADMIN_CONSENT("admin_consent"),
40+
41+
/**
42+
* User will not be shown an interactive prompt
43+
*/
44+
NONE("none");
4045

4146
private String prompt;
4247

0 commit comments

Comments
 (0)