【问题标题】:redirect to http back after https in tomcat + jsf在tomcat + jsf中的https之后重定向到http
【发布时间】:2010-07-01 11:48:08
【问题描述】:

我有一个想在 https 中显示的登录页面。验证用户后,我想将他转移回http。

所以我在 web.xml 中声明了

<security-constraint>
  <web-resource-collection>
   <web-resource-name>Login and Restricted Space URLs</web-resource-name>
   <url-pattern>/general/enter.jsf</url-pattern>
  </web-resource-collection>  
  <user-data-constraint>
   <transport-guarantee>CONFIDENTIAL</transport-guarantee>
  </user-data-constraint>
 </security-constraint>

 <security-constraint>
  <web-resource-collection>
   <web-resource-name>Rest of the Application</web-resource-name>
   <url-pattern>/general/home.jsf</url-pattern>
     </web-resource-collection>
  <user-data-constraint>
   <transport-guarantee>NONE</transport-guarantee>
  </user-data-constraint>
 </security-constraint>

我看到登录页面在 https 中。

但在我的行动中:

public String doLogin() throws Exception {
  ...
  User user = service.getUserByNameAndCompany(name, company);
  ......
                return "/general/home.jsf";
 }

bean 将用户重定向到

https://mycomputer:8443/MYProject/general/home.jsf

我希望它回来

http://mycomputer:8080/MYProject/general/home.jsf

我该怎么做?

【问题讨论】:

  • 虽然这种方法可以保护密码,但它会暴露 sessionid cookie。因此,可以嗅探流量的攻击者可以充当受害者。
  • 那么您建议如何保护 sessionid cookie?

标签: java tomcat jsf


【解决方案1】:

JSF 导航会将您重定向到同一应用程序内的页面(这意味着您只能在 https: //mycomputer:8080/MYProject 内导航)。

您可以做的是导航到像/general/redirect.jsf 这样的页面,然后使用标题或javascript 重定向到您想要的网址。

【讨论】:

  • 但标头或 javascript 可能需要完整的 URL,例如:http://mycomputer:8080/MYProject/general/home.jsf 并且我不想放置完整的 URL,因为计算机名称/port/project 可能会改变。我希望它与应用程序相关..
  • 使用配置文件左右或将8080/8443更改为80/443这样就不需要使用端口号,只需将URL中的“https”替换为“http”即可。使用ExternalContext#redirect() 以编程方式重定向,然后使用return null(或仅声明方法void)。
  • 您可以从请求中读取 URL,然后解析并删除 URL 中的“s”:您可以按照 BalusC 的建议在 Javascript o 中以编程方式在您的支持 bean 中执行此操作。
猜你喜欢
  • 1970-01-01
  • 2015-04-05
  • 1970-01-01
  • 2020-03-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-01-07
相关资源
最近更新 更多