-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #851 from AzureAD/avdunn/ciam-custom
Add support for CIAM custom authority
- Loading branch information
Showing
14 changed files
with
201 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,5 +4,5 @@ | |
package com.microsoft.aad.msal4j; | ||
|
||
enum AuthorityType { | ||
AAD, ADFS, B2C, CIAM | ||
AAD, ADFS, B2C, CIAM, OIDC | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
msal4j-sdk/src/main/java/com/microsoft/aad/msal4j/OidcAuthority.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
package com.microsoft.aad.msal4j; | ||
|
||
import java.net.MalformedURLException; | ||
import java.net.URL; | ||
|
||
public class OidcAuthority extends Authority { | ||
//Part of the OpenIdConnect standard, this is appended to the authority to create the endpoint that has OIDC metadata | ||
static final String WELL_KNOWN_OPENID_CONFIGURATION = ".well-known/openid-configuration"; | ||
private static final String AUTHORITY_FORMAT = "https://%s/%s/"; | ||
|
||
OidcAuthority(URL authorityUrl) throws MalformedURLException { | ||
super(createOidcDiscoveryUrl(authorityUrl), AuthorityType.OIDC); | ||
|
||
this.authority = String.format(AUTHORITY_FORMAT, host, tenant); | ||
} | ||
|
||
private static URL createOidcDiscoveryUrl(URL originalAuthority) throws MalformedURLException { | ||
String authority = originalAuthority.toString(); | ||
authority += WELL_KNOWN_OPENID_CONFIGURATION; | ||
|
||
return new URL(authority); | ||
} | ||
|
||
void setAuthorityProperties(OidcDiscoveryResponse instanceDiscoveryResponse) { | ||
this.authorizationEndpoint = instanceDiscoveryResponse.authorizationEndpoint(); | ||
this.tokenEndpoint = instanceDiscoveryResponse.tokenEndpoint(); | ||
this.deviceCodeEndpoint = instanceDiscoveryResponse.deviceCodeEndpoint(); | ||
this.selfSignedJwtAudience = this.tokenEndpoint; | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
msal4j-sdk/src/main/java/com/microsoft/aad/msal4j/OidcDiscoveryProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
package com.microsoft.aad.msal4j; | ||
|
||
class OidcDiscoveryProvider { | ||
|
||
static OidcDiscoveryResponse performOidcDiscovery(OidcAuthority authority, AbstractClientApplicationBase clientApplication) { | ||
HttpRequest httpRequest = new HttpRequest( | ||
HttpMethod.GET, | ||
authority.canonicalAuthorityUrl.toString()); | ||
|
||
IHttpResponse httpResponse = ((HttpHelper)clientApplication.serviceBundle.getHttpHelper()).executeHttpRequest(httpRequest); | ||
|
||
OidcDiscoveryResponse response = JsonHelper.convertJsonToObject(httpResponse.body(), OidcDiscoveryResponse.class); | ||
|
||
if (httpResponse.statusCode() != HttpHelper.HTTP_STATUS_200) { | ||
throw MsalServiceExceptionFactory.fromHttpResponse(httpResponse); | ||
} | ||
|
||
return response; | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
msal4j-sdk/src/main/java/com/microsoft/aad/msal4j/OidcDiscoveryResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
package com.microsoft.aad.msal4j; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import lombok.AccessLevel; | ||
import lombok.Getter; | ||
import lombok.experimental.Accessors; | ||
|
||
@Accessors(fluent = true) | ||
@Getter(AccessLevel.PACKAGE) | ||
class OidcDiscoveryResponse { | ||
|
||
@JsonProperty("authorization_endpoint") | ||
private String authorizationEndpoint; | ||
|
||
@JsonProperty("token_endpoint") | ||
private String tokenEndpoint; | ||
|
||
@JsonProperty("device_authorization_endpoint") | ||
private String deviceCodeEndpoint; | ||
} |