如何在注销页面上对用户进行身份验证

How to authenticate user on logout page

我是 cas 服务器的新手,现在我遇到了另一个问题。当用户点击注销按钮时,应用程序重定向到

https://localhost:8443/cas/logout

我想在成功注销后向用户显示一条消息,该页面的其余部分与登录页面相同,我的意思是有用于获取用户名和密码的输入以及一个提交按钮。

我在 spring-security.xml 文件中的配置是这样的:

<logout logout-url="/logout" delete-cookies="true"
        invalidate-session="true"
        logout-success-url="https://${cas.server.host}/cas/logout?service=https://${cas.service.host}/MyApp1/" />

<b:bean id="requestSingleLogoutFilter"
    class="org.springframework.security.web.authentication.logout.LogoutFilter"
    p:filterProcessesUrl="/logout">
    <b:constructor-arg value="https://${cas.server.host}/cas/logout" />
    <b:constructor-arg>
        <b:bean
            class="org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler" />
    </b:constructor-arg>
</b:bean>

那我该怎么办?

类似的东西会帮助你

<c:choose>
    <c:when test="${empty param.name}">// name is the Request Parameter
        Please enter your name.
    </c:when>
    <c:otherwise>
        Hello <b><c:out value="${param.name}" /></b>!
    </c:otherwise>
</c:choose>

点击注销时发送这样的请求

https://localhost:8443/cas/login.jsp?logout=Thanks for Visiting Cas !!!

您所要做的就是将以下更改添加到您的 spring-security.xml

<b:bean id="requestSingleLogoutFilter"
    class="org.springframework.security.web.authentication.logout.LogoutFilter"
    p:filterProcessesUrl="/logout">
    <b:constructor-arg value="https://${cas.server.host}/cas/logout?service=https://${cas.service.host}/MyApp1/j_spring_cas_security_check" />
    <b:constructor-arg>
        <b:bean
            class="org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler" />
    </b:constructor-arg>
</b:bean>

并取消注释

cas.logout.followServiceRedirects=true

在来自 cas 服务器应用程序的 cas.properties 文件中。

希望对您有所帮助。

此致。