Skip to content
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

Fix custom url redirection issue #6222

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,8 @@ public ExternalIdPConfig getIdPConfigByRealm(String realm, String tenantDomain)
public String getAuthenticationEndpointURL() {

return buildUrl(AUTHENTICATION_ENDPOINT,
FileBasedConfigurationBuilder.getInstance()::getAuthenticationEndpointURL);
FileBasedConfigurationBuilder.getInstance()::getAuthenticationEndpointURL,
FileBasedConfigurationBuilder.getInstance()::getAuthenticationEndpointURLV2);
}

public String getAuthenticationEndpointAbsoluteURL() {
Expand All @@ -207,19 +208,22 @@ public String getAuthenticationEndpointAbsoluteURL() {
public String getAuthenticationEndpointRetryURL() {

return buildUrl(AUTHENTICATION_ENDPOINT_RETRY,
FileBasedConfigurationBuilder.getInstance()::getAuthenticationEndpointRetryURL);
FileBasedConfigurationBuilder.getInstance()::getAuthenticationEndpointRetryURL,
FileBasedConfigurationBuilder.getInstance()::getAuthenticationEndpointRetryURLV2);
}

public String getAuthenticationEndpointErrorURL() {

return buildUrl(AUTHENTICATION_ENDPOINT_ERROR,
FileBasedConfigurationBuilder.getInstance()::getAuthenticationEndpointErrorURL);
FileBasedConfigurationBuilder.getInstance()::getAuthenticationEndpointErrorURL,
FileBasedConfigurationBuilder.getInstance()::getAuthenticationEndpointErrorURLV2);
}

public String getAuthenticationEndpointWaitURL() {

return buildUrl(AUTHENTICATION_ENDPOINT_WAIT,
FileBasedConfigurationBuilder.getInstance()::getAuthenticationEndpointWaitURL);
FileBasedConfigurationBuilder.getInstance()::getAuthenticationEndpointWaitURL,
FileBasedConfigurationBuilder.getInstance()::getAuthenticationEndpointWaitURLV2);
}

public String getAccountRecoveryEndpointAbsolutePath() {
Expand All @@ -235,13 +239,15 @@ public String getAccountRecoveryEndpointPath() {
public String getIdentifierFirstConfirmationURL() {

return buildUrl(IDENTIFIER_FIRST_CONFIRMATION,
FileBasedConfigurationBuilder.getInstance()::getIdentifierFirstConfirmationURL);
FileBasedConfigurationBuilder.getInstance()::getIdentifierFirstConfirmationURL,
FileBasedConfigurationBuilder.getInstance()::getIdentifierFirstConfirmationURLV2);
}

public String getAuthenticationEndpointPromptURL() {

return buildUrl(AUTHENTICATION_ENDPOINT_DYNAMIC_PROMPT,
FileBasedConfigurationBuilder.getInstance()::getAuthenticationEndpointPromptURL);
FileBasedConfigurationBuilder.getInstance()::getAuthenticationEndpointPromptURL,
FileBasedConfigurationBuilder.getInstance()::getAuthenticationEndpointPromptURLV2);
}

/**
Expand All @@ -252,7 +258,8 @@ public String getAuthenticationEndpointPromptURL() {
public String getAuthenticationEndpointMissingClaimsURL() {

return buildUrl(AUTHENTICATION_ENDPOINT_MISSING_CLAIMS_PROMPT,
FileBasedConfigurationBuilder.getInstance()::getAuthenticationEndpointMissingClaimsURL);
FileBasedConfigurationBuilder.getInstance()::getAuthenticationEndpointMissingClaimsURL,
FileBasedConfigurationBuilder.getInstance()::getAuthenticationEndpointMissingClaimsURLV2);
}

/**
Expand Down Expand Up @@ -324,11 +331,21 @@ private String preprocessEndpointPath(String endpointPath) {
}
}

@Deprecated
private String buildUrl(String defaultContext, Supplier<String> getValueFromFileBasedConfig) {

return buildUrl(defaultContext, getValueFromFileBasedConfig, null);
}

private String buildUrl(String defaultContext, Supplier<String> getValueFromFileBasedConfig,
Supplier<String> getV2VaueFromFileBasedConfig) {

String applicationName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getApplicationName();
if (IdentityTenantUtil.isTenantQualifiedUrlsEnabled()) {
try {
if (StringUtils.isNotBlank(getV2VaueFromFileBasedConfig.get())) {
return getV2VaueFromFileBasedConfig.get();
}
String organizationId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getOrganizationId();
ServiceURLBuilder serviceURLBuilder =
ServiceURLBuilder.create().addPath(defaultContext).setOrganization(organizationId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ public class FileBasedConfigurationBuilder {
private String identifierFirstConfirmationURL;
private String authenticationEndpointPromptURL;
private String authenticationEndpointMissingClaimsURL;
private String authenticationEndpointURLV2;
private String authenticationEndpointRetryURLV2;
private String authenticationEndpointErrorURLV2;
private String authenticationEndpointWaitURLV2;
private String identifierFirstConfirmationURLV2;
private String authenticationEndpointPromptURLV2;
private String authenticationEndpointMissingClaimsURLV2;
private boolean allowCustomClaimMappingsForAuthenticators = false;
private boolean allowMergingCustomClaimMappingsWithDefaultClaimMappings = false;
private boolean allowConsentPageRedirectParams = false;
Expand Down Expand Up @@ -184,6 +191,8 @@ private void buildConfiguration(InputStream inStream) throws IOException {
readAuthenticationEndpointPromptURL(rootElement);
readAuthenticationEndpointMissingClaimsURL(rootElement);

readAuthenticationEndpointV2URL(rootElement);

//########### Read tenant data listener URLs ###########
readTenantDataListenerURLs(rootElement);

Expand Down Expand Up @@ -238,6 +247,23 @@ private void buildConfiguration(InputStream inStream) throws IOException {
}
}

private void readAuthenticationEndpointV2URL(OMElement documentElement) {

OMElement v2UrlElem = documentElement.getFirstChildWithName(IdentityApplicationManagementUtil.
getQNameWithIdentityApplicationNS(FrameworkConstants.Config.V2));

//########### Read Authentication Endpoint V2 URL ###########
if (v2UrlElem != null) {
readAuthenticationEndpointURLV2(v2UrlElem);
readAuthenticationEndpointRetryURLV2(v2UrlElem);
readAuthenticationEndpointErrorURLV2(v2UrlElem);
readAuthenticationEndpointWaitURLV2(v2UrlElem);
readIdentifierFirstConfirmationURLV2(v2UrlElem);
readAuthenticationEndpointPromptURLV2(v2UrlElem);
readAuthenticationEndpointMissingClaimsURLV2(v2UrlElem);
}
}

private void readChildElements(OMElement serverConfig, Stack<String> nameStack) {

for (Iterator childElements = serverConfig.getChildElements(); childElements.hasNext(); ) {
Expand Down Expand Up @@ -601,6 +627,15 @@ private void readAuthenticationEndpointURL(OMElement documentElement) {
}
}

private void readAuthenticationEndpointURLV2(OMElement documentElement) {

OMElement authEndpointURLElem = documentElement.getFirstChildWithName(IdentityApplicationManagementUtil.
getQNameWithIdentityApplicationNS(FrameworkConstants.Config.QNAME_AUTHENTICATION_ENDPOINT_URL));
if (authEndpointURLElem != null) {
authenticationEndpointURLV2 = IdentityUtil.fillURLPlaceholders(authEndpointURLElem.getText());
}
}

private void readAuthenticationEndpointRetryURL(OMElement documentElement) {
OMElement authEndpointRetryURLElem = documentElement.getFirstChildWithName(IdentityApplicationManagementUtil.
getQNameWithIdentityApplicationNS(FrameworkConstants.Config.QNAME_AUTHENTICATION_ENDPOINT_RETRY_URL));
Expand All @@ -610,6 +645,17 @@ private void readAuthenticationEndpointRetryURL(OMElement documentElement) {
}
}

private void readAuthenticationEndpointRetryURLV2(OMElement documentElement) {

OMElement authEndpointRetryURLElem = documentElement.getFirstChildWithName(IdentityApplicationManagementUtil.
getQNameWithIdentityApplicationNS(
FrameworkConstants.Config.QNAME_AUTHENTICATION_ENDPOINT_RETRY_URL));

if (authEndpointRetryURLElem != null) {
authenticationEndpointRetryURLV2 = IdentityUtil.fillURLPlaceholders(authEndpointRetryURLElem.getText());
}
}

private void readAuthenticationEndpointErrorURL(OMElement documentElement) {
OMElement authEndpointErrorURLElem = documentElement.getFirstChildWithName(IdentityApplicationManagementUtil.
getQNameWithIdentityApplicationNS(FrameworkConstants.Config.QNAME_AUTHENTICATION_ENDPOINT_ERROR_URL));
Expand All @@ -619,6 +665,17 @@ private void readAuthenticationEndpointErrorURL(OMElement documentElement) {
}
}

private void readAuthenticationEndpointErrorURLV2(OMElement documentElement) {

OMElement authEndpointErrorURLElem = documentElement.getFirstChildWithName(IdentityApplicationManagementUtil.
getQNameWithIdentityApplicationNS(
FrameworkConstants.Config.QNAME_AUTHENTICATION_ENDPOINT_ERROR_URL));

if (authEndpointErrorURLElem != null) {
authenticationEndpointErrorURLV2 = IdentityUtil.fillURLPlaceholders(authEndpointErrorURLElem.getText());
}
}

private void readAuthenticationEndpointWaitURL(OMElement documentElement) {
OMElement authEndpointWaitURLElem = documentElement.getFirstChildWithName(IdentityApplicationManagementUtil.
getQNameWithIdentityApplicationNS(FrameworkConstants.Config.QNAME_AUTHENTICATION_ENDPOINT_WAIT_URL));
Expand All @@ -628,6 +685,16 @@ private void readAuthenticationEndpointWaitURL(OMElement documentElement) {
}
}

private void readAuthenticationEndpointWaitURLV2(OMElement documentElement) {

OMElement authEndpointWaitURLElem = documentElement.getFirstChildWithName(IdentityApplicationManagementUtil.
getQNameWithIdentityApplicationNS(FrameworkConstants.Config.QNAME_AUTHENTICATION_ENDPOINT_WAIT_URL));

if (authEndpointWaitURLElem != null) {
authenticationEndpointWaitURLV2 = IdentityUtil.fillURLPlaceholders(authEndpointWaitURLElem.getText());
}
}

private void readIdentifierFirstConfirmationURL(OMElement documentElement) {
OMElement readIDFConfirmationElement = documentElement.getFirstChildWithName(
IdentityApplicationManagementUtil.getQNameWithIdentityApplicationNS(
Expand All @@ -638,6 +705,17 @@ private void readIdentifierFirstConfirmationURL(OMElement documentElement) {
}
}

private void readIdentifierFirstConfirmationURLV2(OMElement documentElement) {

OMElement readIDFConfirmationElement = documentElement.getFirstChildWithName(
IdentityApplicationManagementUtil.getQNameWithIdentityApplicationNS(
FrameworkConstants.Config.QNAME_AUTHENTICATION_ENDPOINT_IDF_CONFIRM_URL));

if (readIDFConfirmationElement != null) {
identifierFirstConfirmationURLV2 = IdentityUtil.fillURLPlaceholders(readIDFConfirmationElement.getText());
}
}

private void readAuthenticationEndpointPromptURL(OMElement documentElement) {
OMElement authEndpointPromptURLElem = documentElement.getFirstChildWithName(IdentityApplicationManagementUtil.
getQNameWithIdentityApplicationNS(FrameworkConstants.Config.QNAME_AUTHENTICATION_ENDPOINT_PROMPT_URL));
Expand All @@ -647,6 +725,18 @@ private void readAuthenticationEndpointPromptURL(OMElement documentElement) {
}
}

private void readAuthenticationEndpointPromptURLV2(OMElement documentElement) {

OMElement authEndpointPromptURLElem = documentElement.getFirstChildWithName(IdentityApplicationManagementUtil.
getQNameWithIdentityApplicationNS(
FrameworkConstants.Config.QNAME_AUTHENTICATION_ENDPOINT_PROMPT_URL));

if (authEndpointPromptURLElem != null) {
authenticationEndpointPromptURLV2 = IdentityUtil.fillURLPlaceholders(authEndpointPromptURLElem.getText());
}
}


private void readAuthenticationEndpointMissingClaimsURL(OMElement documentElement) {
OMElement authEndpointMissingClaimsURLElem = documentElement.getFirstChildWithName
(IdentityApplicationManagementUtil.getQNameWithIdentityApplicationNS(FrameworkConstants.Config
Expand All @@ -658,6 +748,18 @@ private void readAuthenticationEndpointMissingClaimsURL(OMElement documentElemen
}
}

private void readAuthenticationEndpointMissingClaimsURLV2(OMElement documentElement) {

OMElement authEndpointMissingClaimsURLElem = documentElement.getFirstChildWithName
(IdentityApplicationManagementUtil.getQNameWithIdentityApplicationNS(FrameworkConstants.Config
.QNAME_AUTHENTICATION_ENDPOINT_MISSING_CLAIMS_URL));

if (authEndpointMissingClaimsURLElem != null) {
authenticationEndpointMissingClaimsURLV2 = IdentityUtil.fillURLPlaceholders
(authEndpointMissingClaimsURLElem.getText());
}
}

public String getAuthenticationEndpointMissingClaimsURL() {
return authenticationEndpointMissingClaimsURL;
}
Expand All @@ -666,6 +768,16 @@ public void setAuthenticationEndpointMissingClaimsURL(String authenticationEndpo
this.authenticationEndpointMissingClaimsURL = authenticationEndpointMissingClaimsURL;
}

public String getAuthenticationEndpointMissingClaimsURLV2() {
sandushi marked this conversation as resolved.
Show resolved Hide resolved

return authenticationEndpointMissingClaimsURLV2;
}

public void setAuthenticationEndpointMissingClaimsURLV2(String authenticationEndpointMissingClaimsURLV2) {

this.authenticationEndpointMissingClaimsURLV2 = authenticationEndpointMissingClaimsURLV2;
}

private void readCacheTimeOut(OMElement cacheTimeoutElem, String value) {
Integer timeout;

Expand Down Expand Up @@ -1001,6 +1113,16 @@ public void setAuthenticationEndpointURL(String authenticationEndpointURL) {
this.authenticationEndpointURL = authenticationEndpointURL;
}

public String getAuthenticationEndpointURLV2() {

return authenticationEndpointURLV2;
}

public void setAuthenticationEndpointURLV2(String authenticationEndpointURLV2) {

this.authenticationEndpointURLV2 = authenticationEndpointURLV2;
}

public String getAuthenticationEndpointRetryURL() {
return authenticationEndpointRetryURL;
}
Expand All @@ -1009,6 +1131,16 @@ public void setAuthenticationEndpointRetryURL(String authenticationEndpointRetry
this.authenticationEndpointRetryURL = authenticationEndpointRetryURL;
}

public String getAuthenticationEndpointRetryURLV2() {

return authenticationEndpointRetryURLV2;
}

public void setAuthenticationEndpointRetryURLV2(String authenticationEndpointRetryURLV2) {

this.authenticationEndpointRetryURLV2 = authenticationEndpointRetryURLV2;
}

public String getAuthenticationEndpointErrorURL() {
return authenticationEndpointErrorURL;
}
Expand All @@ -1017,6 +1149,16 @@ public void setAuthenticationEndpointErrorURL(String authenticationEndpointError
this.authenticationEndpointErrorURL = authenticationEndpointErrorURL;
}

public String getAuthenticationEndpointErrorURLV2() {

return authenticationEndpointErrorURLV2;
}

public void setAuthenticationEndpointErrorURLV2(String authenticationEndpointErrorURLV2) {

this.authenticationEndpointErrorURLV2 = authenticationEndpointErrorURLV2;
}

public String getAuthenticationEndpointWaitURL() {
return authenticationEndpointWaitURL;
}
Expand All @@ -1025,6 +1167,16 @@ public void setAuthenticationEndpointWaitURL(String authenticationEndpointWaitUR
this.authenticationEndpointWaitURL = authenticationEndpointWaitURL;
}

public String getAuthenticationEndpointWaitURLV2() {

return authenticationEndpointWaitURLV2;
}

public void setAuthenticationEndpointWaitURLV2(String authenticationEndpointWaitURLV2) {

this.authenticationEndpointWaitURLV2 = authenticationEndpointWaitURLV2;
}

public String getIdentifierFirstConfirmationURL() {
return identifierFirstConfirmationURL;
}
Expand All @@ -1033,6 +1185,16 @@ public void setIdentifierFirstConfirmationURL(String identifierFirstConfirmation
this.identifierFirstConfirmationURL = identifierFirstConfirmationURL;
}

public String getIdentifierFirstConfirmationURLV2() {

return identifierFirstConfirmationURLV2;
}

public void setIdentifierFirstConfirmationURLV2(String identifierFirstConfirmationURLV2) {

this.identifierFirstConfirmationURLV2 = identifierFirstConfirmationURLV2;
}

public String getAuthenticationEndpointPromptURL() {
return authenticationEndpointPromptURL;
}
Expand All @@ -1041,6 +1203,16 @@ public void setAuthenticationEndpointPromptURL(String authenticationEndpointProm
this.authenticationEndpointPromptURL = authenticationEndpointPromptURL;
}

public String getAuthenticationEndpointPromptURLV2() {

return authenticationEndpointPromptURLV2;
}

public void setAuthenticationEndpointPromptURLV2(String authenticationEndpointPromptURLV2) {

this.authenticationEndpointPromptURLV2 = authenticationEndpointPromptURLV2;
}

/**
* Get the tenant list receiving urls
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ public static class Config {
public static final String QNAME_AUTHENTICATION_ENDPOINT_PROMPT_URL = "AuthenticationEndpointPromptURL";
public static final String QNAME_AUTHENTICATION_ENDPOINT_MISSING_CLAIMS_URL =
"AuthenticationEndpointMissingClaimsURL";
public static final String V2 = "V2";
public static final String QNAME_PROXY_MODE = "ProxyMode";
public static final String QNAME_MAX_LOGIN_ATTEMPT_COUNT = "MaxLoginAttemptCount";
public static final String QNAME_EXTENSIONS = "Extensions";
Expand Down
Loading
Loading