diff --git a/io.asgardeo.java.oidc.sdk/src/main/java/io/asgardeo/java/oidc/sdk/HTTPSessionBasedOIDCProcessor.java b/io.asgardeo.java.oidc.sdk/src/main/java/io/asgardeo/java/oidc/sdk/HTTPSessionBasedOIDCProcessor.java index 99e076e..314efeb 100644 --- a/io.asgardeo.java.oidc.sdk/src/main/java/io/asgardeo/java/oidc/sdk/HTTPSessionBasedOIDCProcessor.java +++ b/io.asgardeo.java.oidc.sdk/src/main/java/io/asgardeo/java/oidc/sdk/HTTPSessionBasedOIDCProcessor.java @@ -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; @@ -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); } diff --git a/io.asgardeo.java.oidc.sdk/src/main/java/io/asgardeo/java/oidc/sdk/SSOAgentConstants.java b/io.asgardeo.java.oidc.sdk/src/main/java/io/asgardeo/java/oidc/sdk/SSOAgentConstants.java index bb98c8d..0980dbe 100644 --- a/io.asgardeo.java.oidc.sdk/src/main/java/io/asgardeo/java/oidc/sdk/SSOAgentConstants.java +++ b/io.asgardeo.java.oidc.sdk/src/main/java/io/asgardeo/java/oidc/sdk/SSOAgentConstants.java @@ -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"; diff --git a/io.asgardeo.java.oidc.sdk/src/main/java/io/asgardeo/java/oidc/sdk/config/FileBasedOIDCConfigProvider.java b/io.asgardeo.java.oidc.sdk/src/main/java/io/asgardeo/java/oidc/sdk/config/FileBasedOIDCConfigProvider.java index 7efe3c4..fbd3125 100644 --- a/io.asgardeo.java.oidc.sdk/src/main/java/io/asgardeo/java/oidc/sdk/config/FileBasedOIDCConfigProvider.java +++ b/io.asgardeo.java.oidc.sdk/src/main/java/io/asgardeo/java/oidc/sdk/config/FileBasedOIDCConfigProvider.java @@ -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)) ? @@ -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); diff --git a/io.asgardeo.java.oidc.sdk/src/main/java/io/asgardeo/java/oidc/sdk/config/model/OIDCAgentConfig.java b/io.asgardeo.java.oidc.sdk/src/main/java/io/asgardeo/java/oidc/sdk/config/model/OIDCAgentConfig.java index 248e6eb..92ab003 100644 --- a/io.asgardeo.java.oidc.sdk/src/main/java/io/asgardeo/java/oidc/sdk/config/model/OIDCAgentConfig.java +++ b/io.asgardeo.java.oidc.sdk/src/main/java/io/asgardeo/java/oidc/sdk/config/model/OIDCAgentConfig.java @@ -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; @@ -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. *