簡體   English   中英

禁用Spring Security https重定向

[英]Disable spring security https redirecting

我正在使用Web應用程序,並將ssl證書配置為在Tomcat中的https上運行。

<Connector port="8080" protocol="org.apache.coyote.http11.Http11NioProtocol"
           maxThreads="150" SSLEnabled="true" clientAuth="false" keystoreFile="conf/expchannel.pfx" keystorePass="***" keystoreType="PKCS12">

由於某些原因,客戶端希望在8080端口上運行它。 應該沒關系。

問題出在Spring安全性登錄攔截器上。 收到請求后,它將自動重定向到登錄頁面,但由於未知原因,它使用8443端口,該端口將永遠不會提供服務(以超時結束)

組態:

<security:http auto-config="true" use-expressions="true">   
    <security:csrf disabled="true"/>
    <!-- Other pages only autenticated  -->
    <security:intercept-url pattern="/pages/userManagement.xhtml" access="hasRole('ROLE_ADMIN')" />
    <security:intercept-url pattern="/pages/performanceMonitoring.xhtml" access="hasRole('ROLE_ADMIN')" />
    <security:intercept-url pattern="/pages/**" access="hasRole('ROLE_USER')" />

    <security:session-management invalid-session-url="/sessionExpired.xhtml">
    </security:session-management>

    <!-- Set the login page and what to do if login fails -->
    <security:form-login login-page="/login.xhtml" authentication-failure-url="/loginFail.xhtml" 
        default-target-url="/pages/statusOverview.xhtml" />
    <security:csrf/>
</security:http>

在7080端口上運行的其他應用程序實例不存在此問題,我猜想有某種隱藏的默認行為,可以在https請求的情況下將端口從8080-> 8443准確地更改。

有沒有辦法禁用此行為? 我在尋找答案,但沒有找到任何答案。 我發現的唯一解決方案是在spring配置中顯式設置http和https端口,這對我來說似乎不合適。 我希望它可以在tomcat配置上進行配置,而不是針對每個Web應用程序進行單獨配置。

謝謝你的幫助。

您需要在該連接器上設置secure="true"以及scheme="https"

請注意,將端口8080用於安全HTTP就像將端口80用於純文本HTTP: Surprise

8443來自Tomcat在連接器上的默認redirectPort設置:Tomcat(或可能是Spring)將用戶重定向到它認為是“安全”的連接器,因為所有登錄都應通過TLS執行。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM