Skip to content

Commit

Permalink
Fix Asgardeo Java OIDC app redirection Issue
Browse files Browse the repository at this point in the history
  • Loading branch information
ChanikaRuchini committed Mar 21, 2022
1 parent c08eedd commit f1b4f41
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.util.Arrays;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
Expand Down Expand Up @@ -63,6 +65,11 @@ public void sendForLogin(HttpServletRequest request, HttpServletResponse respons

HttpSession session = request.getSession();
RequestContext requestContext = defaultOIDCManager.sendForLogin(request, response);
if (request.getRequestURI() != null) {
String[] uri = request.getRequestURI().toString().split("/");
String redirectPageURI = String.join("/", Arrays.copyOfRange(uri, 2, uri.length));
requestContext.setParameter(SSOAgentConstants.REDIRECT_URI_KEY, redirectPageURI);
}
session.setAttribute(SSOAgentConstants.REQUEST_CONTEXT, requestContext);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,10 @@ public class SSOAgentConstants {
public static final String CONSUMER_SECRET = "consumerSecret";
public static final String CALL_BACK_URL = "callBackURL";
public static final String SKIP_URIS = "skipURIs";
public static final String REDIRECT_URI_KEY = "redirectURI";
public static final String INDEX_PAGE = "indexPage";
public static final String ERROR_PAGE = "errorPage";
public static final String HOME_PAGE = "homePage";
public static final String LOGOUT_URL = "logoutURL";
public static final String SCOPE = "scope";
public static final String OAUTH2_GRANT_TYPE = "grantType";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ private void initConfig(Properties properties) throws SSOAgentClientException {
new Secret(properties.getProperty(SSOAgentConstants.CONSUMER_SECRET)) : null;
String indexPage = properties.getProperty(SSOAgentConstants.INDEX_PAGE);
String errorPage = properties.getProperty(SSOAgentConstants.ERROR_PAGE);
String homePage = properties.getProperty(SSOAgentConstants.HOME_PAGE);
String logoutURL = properties.getProperty(SSOAgentConstants.LOGOUT_URL);
JWSAlgorithm jwsAlgorithm =
StringUtils.isNotBlank(properties.getProperty(SSOAgentConstants.ID_TOKEN_SIGN_ALG)) ?
Expand Down Expand Up @@ -149,6 +150,7 @@ private void initConfig(Properties properties) throws SSOAgentClientException {
oidcAgentConfig.setConsumerSecret(consumerSecret);
oidcAgentConfig.setIndexPage(indexPage);
oidcAgentConfig.setErrorPage(errorPage);
oidcAgentConfig.setHomePage(homePage);
oidcAgentConfig.setLogoutURL(logoutURL);
oidcAgentConfig.setIssuer(issuer);
oidcAgentConfig.setSkipURIs(skipURIs);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public class OIDCAgentConfig {
private Secret consumerSecret;
private String indexPage;
private String errorPage;
private String homePage;
private String logoutURL;
private URI callbackUrl;
private Scope scope;
Expand Down Expand Up @@ -136,6 +137,26 @@ public void setErrorPage(String errorPage) {
this.errorPage = errorPage;
}

/**
* Returns the home page of the OIDC agent.
*
* @return Home page of the OIDC agent.
*/
public String getHomePage() {

return homePage;
}

/**
* Sets the home page for the OIDC agent.
*
* @param homePage The home page of the OIDC agent.
*/
public void setHomePage(String homePage) {

this.homePage = homePage;
}

/**
* Returns the logout URL of the OIDC agent.
*
Expand Down

0 comments on commit f1b4f41

Please sign in to comment.