【问题标题】:Spring Security Https Wrong PortSpring Security Https端口错误
【发布时间】:2011-09-19 01:48:42
【问题描述】:

当我在我的网站上使用我的 https 登录页面时,spring security forward 使用了错误的端口:

https://www.mywebsite.com:80/j_spring_security_check?j_username=test&j_password=test&_spring_security_remember_me=false

我的登录 bean 执行以下操作:

    ExternalContext ec = context.getExternalContext();


    String encodedURL = ec.encodeResourceURL(ec.getRequestContextPath() + "/j_spring_security_check?j_username=" + userId + "&j_password=" + password + "&_spring_security_remember_me=" + rememberMe );
    logger.info(encodedURL);
    ec.redirect(encodedURL);

也试过了:

ExternalContext context = FacesContext.getCurrentInstance()
            .getExternalContext();

    RequestDispatcher dispatcher = ((ServletRequest) context.getRequest())
            .getRequestDispatcher("/j_spring_security_check");

    dispatcher.forward((ServletRequest) context.getRequest(),
            (ServletResponse) context.getResponse());

    FacesContext.getCurrentInstance().responseComplete();
    // It's OK to return null here because Faces is just going to exit.
    return null;

Server.xml:

<Connector port="80" protocol="HTTP/1.1" 
           connectionTimeout="20000" 
            redirectPort="443" />

<Connector port="443" protocol="HTTP/1.1" scheme="https" secure="true"/>

不知道为什么它使用了错误的端口...

【问题讨论】:

    标签: jsf spring-security


    【解决方案1】:

    &lt;Connector port="443" protocol="HTTP/1.1" scheme="https" secure="true"/&gt; 更改为 &lt;Connector port="443" proxyPort="443" protocol="HTTP/1.1" scheme="https" secure="true"/&gt; 成功了

    【讨论】:

      【解决方案2】:

      您需要像这样在命名空间配置中配置 SSL/HTTPS 端口:

      <security:port-mappings>
          <security:port-mapping http="8090" https="8443"/>
          <security:port-mapping http="8080" https="8443"/>
      </security:port-mappings>
      

      【讨论】:

      • 我这样做了...HTTPS 和 HTTP 工作正常。它只是 j_spring_security_check 的登录页面帖子,似乎不起作用......它似乎出于某种原因试图重定向到端口 80 上的 HTTPS 页面。
      猜你喜欢
      • 2012-02-07
      • 2015-09-17
      • 2020-09-15
      • 2012-07-06
      • 1970-01-01
      • 1970-01-01
      • 2016-06-13
      • 2015-06-08
      • 1970-01-01
      相关资源
      最近更新 更多