diff --git a/pom.xml b/pom.xml index 035e9e55b8..a59cbf619a 100644 --- a/pom.xml +++ b/pom.xml @@ -33,7 +33,7 @@ true - 1.5.1 + 1.5.3 runtime compile 2.5.4.SP4 @@ -47,6 +47,7 @@ ${project.build.sourceDirectory}/org/zanata 3.6.2 3.9.17 + 3.0.0.Alpha10 org.jvnet.mock-javamail:mock-javamail - - org.tuckey:urlrewritefilter ${jdbc.groupId}:${jdbc.artifactId} @@ -1768,9 +1766,9 @@ - org.tuckey - urlrewritefilter - 4.0.4 + org.ocpsoft.rewrite + rewrite-servlet + ${rewrite.version} diff --git a/zanata-war/src/main/java/org/zanata/exception/handler/AbstractExceptionHandler.java b/zanata-war/src/main/java/org/zanata/exception/handler/AbstractExceptionHandler.java index 478cce568a..1c6640ebea 100644 --- a/zanata-war/src/main/java/org/zanata/exception/handler/AbstractExceptionHandler.java +++ b/zanata-war/src/main/java/org/zanata/exception/handler/AbstractExceptionHandler.java @@ -71,6 +71,7 @@ protected final void handle(ExceptionEvent event, messages.clear(); messages.addFromResourceBundle(severity, messageKey, messageArgs); urlUtil.redirectTo(redirectUrl); +// TODO urlUtil.forwardTo(redirectPath); // required - "stops" the JSF lifecycle FacesContext.getCurrentInstance().responseComplete(); diff --git a/zanata-war/src/main/java/org/zanata/security/jaas/InternalLoginModule.java b/zanata-war/src/main/java/org/zanata/security/jaas/InternalLoginModule.java index 0f379d74c2..b64b62578c 100644 --- a/zanata-war/src/main/java/org/zanata/security/jaas/InternalLoginModule.java +++ b/zanata-war/src/main/java/org/zanata/security/jaas/InternalLoginModule.java @@ -18,7 +18,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.tuckey.web.filters.urlrewrite.Run; import org.zanata.security.SimpleGroup; import org.zanata.security.SimplePrincipal; import org.zanata.security.ZanataIdentity; diff --git a/zanata-war/src/main/java/org/zanata/servlet/UrlRewriteConfig.java b/zanata-war/src/main/java/org/zanata/servlet/UrlRewriteConfig.java new file mode 100644 index 0000000000..3fe4268ae4 --- /dev/null +++ b/zanata-war/src/main/java/org/zanata/servlet/UrlRewriteConfig.java @@ -0,0 +1,112 @@ +package org.zanata.servlet; + +import org.ocpsoft.rewrite.annotation.RewriteConfiguration; +import org.ocpsoft.rewrite.config.Configuration; +import org.ocpsoft.rewrite.config.ConfigurationBuilder; +import org.ocpsoft.rewrite.config.Direction; +import org.ocpsoft.rewrite.servlet.config.Forward; +import org.ocpsoft.rewrite.servlet.config.HttpConfigurationProvider; +import org.ocpsoft.rewrite.servlet.config.Path; +import org.ocpsoft.rewrite.servlet.config.Redirect; +import org.ocpsoft.rewrite.servlet.config.rule.Join; + +import javax.servlet.ServletContext; + +/* + * This class replaces urlrewrite.xml, with simpler bidirectional mappings for external/internal URLs. + */ + +// TODO copy comments from urlrewrite.xml +// TODO delete urlrewrite.xml and tuckey dependency +@RewriteConfiguration +public class UrlRewriteConfig extends HttpConfigurationProvider { + + @Override + public Configuration getConfiguration(final ServletContext context) { + String contextPath = context.getContextPath(); + // NB: inbound rules are processed in order, outbound rules in reverse order (as of Rewrite 3.0.0.Alpha1) + return ConfigurationBuilder.begin() + + // TODO test this + .addRule() + .when(Direction.isInbound().and(Path.matches("/seam/resource/restv1/{path}"))) + .perform(Forward.to("/rest/{path}")) + .where("path").matches(".*") + + .addRule() + .when(Direction.isInbound().and(Path.matches("/iteration/files/{projectSlug}/{iterationSlug}"))) + .perform(Redirect.permanent(contextPath + "/iteration/view/{projectSlug}/{iterationSlug}/documents")) + + .addRule() + .when(Direction.isInbound().and(Path.matches("/iteration/source_files/{projectSlug}/{iterationSlug}"))) + .perform(Redirect.permanent(contextPath + "/iteration/view/{projectSlug}/{iterationSlug}/documents")) + + + .addRule(Join.path("/").to("/home.seam")) + .addRule(Join.path("/account/activate/{key}").to("/account/activate.seam")) + //.addRule(Join.path("/account/changepassword").to("/account/changepassword.seam")) + .addRule(Join.path("/account/google_password_reset_request").to("/account/google_password_reset_request.seam")) + .addRule(Join.path("/account/password_reset/{key}").to("/account/password_reset.seam")) + .addRule(Join.path("/account/password_reset_request").to("/account/password_reset_request.seam")) + .addRule(Join.path("/account/inactive").to("/account/inactive_account.seam")) + .addRule(Join.path("/account/klogin").to("/account/klogin.seam")) + .addRule(Join.path("/account/sign_in").to("/account/login.seam")) + .addRule(Join.path("/account/register").to("/account/register.seam")) + .addRule(Join.path("/account/sign_out").to("/account/logout.seam")) + .addRule(Join.path("/account/validate_email/{key}").to("/account/email_validation.seam")) + .addRule(Join.path("/admin/").to("/admin/home.seam")) + .addRule(Join.pathNonBinding("/admin/{page}").to("/admin/{page}.seam")) + .addRule(Join.path("/dashboard/").to("/dashboard/home.seam")) + .addRule(Join.path("/error/").to("/error.seam")) + .addRule(Join.pathNonBinding("/error/{path}").to("/error/{path}.seam")) + .addRule(Join.path("/glossary/").to("/glossary/view.seam")) + //.addRule(Join.path("/help/view").to("/help/view.seam")) + .addRule(Join.path("/iteration/view/{projectSlug}/{iterationSlug}").to("/iteration/view.seam")) + .addRule(Join.path("/iteration/view/{projectSlug}/{iterationSlug}/{section}").to("/iteration/view.seam")).when(Direction.isInbound()) + /* JSF serves zanata-assets with suffix of .seam only. + This is to make sure any reference to zanata-assets + without .seam can access the resource. + e.g. jars/assets/style.css forwards to + jars/assets/style.css.seam + */ + .addRule(Join.path("/javax.faces.resource/jars/assets/{path}") + .to("/javax.faces.resource/jars/assets/{path}.seam")) + .when(Direction.isInbound()) + .where("path").matches(".*(?/* - - - - - - - - - - - - UrlRewriteFilter - org.tuckey.web.filters.urlrewrite.UrlRewriteFilter - - logLevel - slf4j - - - statusPath - /rwstatus - - - - statusEnabled - true - - - - - - UrlRewriteFilter - /* - - - - - - - - - - - - @@ -328,20 +284,6 @@ /files/upload/* - - Restrict raw XHTML Documents diff --git a/zanata-war/src/main/webapp/WEB-INF/faces-config.xml b/zanata-war/src/main/webapp/WEB-INF/faces-config.xml index 896691015d..64fad76a30 100644 --- a/zanata-war/src/main/webapp/WEB-INF/faces-config.xml +++ b/zanata-war/src/main/webapp/WEB-INF/faces-config.xml @@ -344,6 +344,7 @@ + persisted /iteration/view.xhtml diff --git a/zanata-war/src/main/webapp/WEB-INF/template/banner.xhtml b/zanata-war/src/main/webapp/WEB-INF/template/banner.xhtml index b1b5177d80..f7e45c8be9 100644 --- a/zanata-war/src/main/webapp/WEB-INF/template/banner.xhtml +++ b/zanata-war/src/main/webapp/WEB-INF/template/banner.xhtml @@ -161,12 +161,13 @@ class="is-hidden--s button">#{msgs['jsf.Signup']} - - #{msgs['jsf.Login']} - + + - - - - - - ^([^?]*)\?dswid=([^&]*)&(.*)$ - $1?$3&dswid=$2 - - - - - 66.187.233.202 - .* - /robots.txt - - - - - 65.55.210.81 - .* - /robots.txt - - - - - ^/dashboard(/([^?]*)\??(.*))?$ - /dashboard/home.seam$3 - - - - - ^/search/([^/]+)/([^/]+)?$ - /search.seam\?query=$1 - - - - - ^/admin/([^/\?\.]+)(\?.*)?$ - /admin/$1.seam$2 - - - - - - ^/language/view/([^/]+)(/([^?]*)\??(.*))?$ - /language/language.seam\?id=$1&$4 - - - - ^/language/list(.+)?$ - /language/home.seam$1 - - - - - - ^/project/add_iteration/([^/]+)/([^/]+)?$ - /project/add_iteration.seam\?projectSlug=$1&copyFromVersionSlug=$2 - - - - ^/project/create(.+)$ - /project/create_project.seam?$1 - - - - ^/project/view/([^/]+)(/([^?]*)\??(.*))?$ - /project/project.seam\?slug=$1&$4 - - - - - - - ^/iteration/view/([^/]+)/([^/]+)(/([^?]*)\??(.*))?$ - - /iteration/view.seam\?projectSlug=$1&iterationSlug=$2&$5 - - - - - - ^/error/?.*\??(.*) - /error.seam?$1 - - - - - - ^/iteration/source_files/([^/]+)/([^/]+)/?$ - - %{context-path}/iteration/view/$1/$2&#documents - - - - - ^/iteration/files/([^/]+)/([^/]+)/([^/]+)/?$ - - %{context-path}/iteration/view/$1/$2&#documents - - - - - - ^/project/view/([^/]+)/iter/([^/]+)/config/?$ - - /project/project.seam\?projectSlug=$1&iterationSlug=$2&actionMethod=project%2Fproject.xhtml%3AconfigurationAction.getData - - - - - ^/project/list(.+)?$ - /project/home.seam$1 - - - - - - ^/account/sign_in(.+)?$ - /account/login.seam$1 - - - - ^/account/klogin(\?.+)?$ - /account/klogin.seam$1 - - - - ^/account/sign_out(.+)?$ - /account/logout.seam$1 - - - - ^/account/register(.+)?$ - /account/register.seam$1 - - - - ^/account/activate/(.+)$ - /account/activate.seam\?key=$1 - - - ^/account/activate(.+)?$ - /account/activate.seam$1 - - - - ^/account/validate_email/([^?]*)(.*)$ - /account/email_validation.seam\?key=$1 - - - - ^/account/changepassword(.+)?$ - /account/changepassword.seam$1 - - - - ^/account/password_reset_request(.+)?$ - /account/password_reset_request.seam$1 - - - - ^/account/password_reset/(.+)$ - /account/password_reset.seam\?key=$1 - - - - ^/account/google_password_reset_request(.+)?$ - /account/google_password_reset_request.seam$1 - - - - ^/account/inactive(.+)?$ - /account/inactive_account.seam$1 - - - - - ^/profile/edit(.+)?$ - /profile/edit.seam$1 - - - - ^/profile/create(.+)?$ - /profile/create_user.seam$1 - - - - ^/profile/add_identity(\?.*)?$ - /profile/add_identity.seam$1 - - - - ^/profile/merge_account(\?.*)?$ - /profile/merge_account.seam$1 - - - - ^/profile/view/(.+)$ - /profile/home.seam\?username=$1 - - - - - ^/profile/$ - /profile/home.seam - - - - - ^/tm/?(\?.*)?$ - /tm/home.seam$1 - - - - ^/tm/create(\?.*)?$ - /tm/create.seam$1 - - - - - ^/$ - /home.seam - - - - ^/admin/$ - /admin/home.seam - - - - ^/error(\?.+)?$ - /error.seam$1 - - - - - - - ^/rest/$ - /rest/index.xrd - - - - ^/seam/resource/restv1/(.+)$ - /rest/$1 - - - - - - ^/version-group/create(.+)$ - /version-group/create_version_group.seam?$1 - - - - - ^/version-group/list(.+)?$ - /version-group/home.seam$1 - - - - ^/version-group/view/([^/]+)(/([^?]*)\??(.*))?$ - - /version-group/version_group.seam\?versionGroupSlug=$1&$4 - - - - - ^/glossary/(.+)?$ - /glossary/view.seam$1 - - - - - ^/webtrans/Application.html(.*)$ - /webtrans/Application.seam$1 - - - - ^/webtrans/translate(.*)$ - /webtrans/Application.seam$1 - - - - - - ^/javax.faces.resource/jars/assets/(.*)(?<!.seam)$ - /javax.faces.resource/jars/assets/$1.seam - - - - ^([^?]*)\?dswid=([^&]*)&(.*)$ - $1?$3&dswid=$2 - - - - ^(/.+)?/dashboard/home.seam(.+)?$ - $1/dashboard/$2 - - - - ^(/.+)?/admin/(.+).seam(.*)$ - $1/admin/$2$3 - - - - ^(/.+)?/language/language.seam\?id=(.+)$ - $1/language/view/$2 - - - ^(/.+)?/language/home.seam(.+)?$ - $1/language/list$2 - - - ^(/.+)?/project/add_iteration.seam\?projectSlug=([^&]+)(?:&copyFromVersionSlug=([^&]+))?(.+)?$ - $1/project/add_iteration/$2/$3 - - - - ^(/.+)?/project/add_iteration.seam\?copyFromVersionSlug=([^&]+)&projectSlug=([^&]+)(.+)?$ - $1/project/add_iteration/$3/$2 - - - - ^(/.+)?/project/create_project.seam(.+)?$ - $1/project/create/$2 - - - ^(/.+)?/project/project.seam\?slug=([^&]+)&?(.*)$ - $1/project/view/$2?$3 - - - ^(/.+)?/project/project.seam\?projectSlug=([^&]+)&iterationSlug=([^&]+)(?:&slug=[^&]+)?&actionMethod=project%2Fproject\.xhtml%3AconfigurationAction\.getData.*$ - $1/project/view/$2/iter/$3/config - - - ^(/.+)?/project/home.seam(.+)?$ - $1/project/list$2 - - - - - ^(/.+)?/iteration/view.seam\?projectSlug=([^&]+)&iterationSlug=([^&]+)(&(.+))?$ - $1/iteration/view/$2/$3 - - - ^(/.+)?/iteration/view.seam\?iterationSlug=([^&]+)&projectSlug=([^&]+)(&(.+))?$ - $1/iteration/view/$3/$2 - - - - ^(/.+)?/account/login.seam(.+)?$ - $1/account/sign_in$2 - - - ^(/.+)?/account/klogin.seam(.+)?$ - $1/account/klogin$2 - - - ^(/.+)?/account/logout.seam(.+)?$ - $1/account/sign_out$2 - - - ^(/.+)?/account/register.seam(.+)?$ - $1/account/register$2 - - - ^(/.+)?/account/activate.seam\?key=(.+)$ - $1/account/activate/$2 - - - ^(/.+)?/account/activate.seam(.+)?$ - $1/account/activate$2 - - - ^(/.+)?/account/email_validation.seam\?key=(.+)$ - $1/account/validate_email/$2 - - - ^(/.+)?/account/password_reset_request.seam(.+)?$ - $1/account/password_reset_request$2 - - - ^(/.+)?/account/password_reset.seam\?key=(.+)$ - $1/account/password_reset/$2 - - - ^(/.+)?/account/google_password_reset_request.seam(.+)?$ - $1/account/google_password_reset_request$2 - - - ^(/.+)?/account/inactive_account.seam(.+)?$ - $1/account/inactive$2 - - - - ^(/.+)?/version-group/home.seam(.+)?$ - $1/version-group/list$2 - - - - ^(/.+)?/version-group/create_version_group.seam(.+)?$ - $1/version-group/create/$2 - - - - ^(/.+)?/version-group/version_group.seam\?versionGroupSlug=(.+)$ - $1/version-group/view/$2 - - - - ^(/.+)?/glossary/view.seam(.+)?$ - $1/glossary/$2 - - - - ^(/.+)?/profile/create_user.seam(.+)?$ - $1/profile/create$2 - - - - ^(/.+)?/profile/merge_account.seam(.+)?$ - $1/profile/merge_account$2 - - - ^(/.+)?/profile/home.seam\?username=(.+)$ - $1/profile/view/$2 - - - - - ^(/.+)?/tm/create.seam(.+)?$ - $1/tm/create$2 - - - - ^(/.+)?/home.seam(.+)?$ - $1/$2 - - - - ^(/.+)?/help/view.seam(.+)?$ - $1/help/view$2 - - - - ^(/.+)?/error.seam(.+)?$ - $1/error$2 - - - - - ^(/.+)?/webtrans/Application.seam(.*)$ - $1/webtrans/translate$2 - - - - - ^(/.+)?/rest/file/translation/(.+).seam(.+)$ - $1/rest/file/translation/$2$3 - - - - ^(/.+)?/rest/file/source/(.+).seam(.+)$ - $1/rest/file/source/$2$3 - - - - ^(/.+)?/rest/tm/(.+).seam(.*)$ - $1/rest/tm/$2$3 - - - diff --git a/zanata-war/src/main/webapp/project/add_iteration.xhtml b/zanata-war/src/main/webapp/project/add_iteration.xhtml index 3843720b7b..b23283f9d4 100644 --- a/zanata-war/src/main/webapp/project/add_iteration.xhtml +++ b/zanata-war/src/main/webapp/project/add_iteration.xhtml @@ -21,7 +21,9 @@

#{msgs['jsf.Projects']} - + +