Fix Logout in OpenID Sample

Fixes gh-8554
This commit is contained in:
Josh Cummings 2020-05-19 11:51:43 -06:00
parent 4ab9da1c53
commit b04b34ba85
No known key found for this signature in database
GPG Key ID: 49EF60DD7FF83443
2 changed files with 8 additions and 2 deletions

View File

@ -16,7 +16,7 @@
<intercept-url pattern="/css/*" access="permitAll"/>
<intercept-url pattern="/js/*" access="permitAll"/>
<intercept-url pattern="/**" access="authenticated"/>
<logout/>
<logout logout-success-url="/"/>
<openid-login login-page="/openidlogin.jsp" user-service-ref="registeringUserService"
authentication-failure-url="/openidlogin.jsp?login_error=true">
<attribute-exchange identifier-match="https://www.google.com/.*">

View File

@ -1,3 +1,4 @@
<%@ page import="org.springframework.security.web.csrf.CsrfToken" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
@ -27,6 +28,11 @@ by the application and will be recognized if you return.
<p>
Your principal object is....: <%= request.getUserPrincipal() %>
</p>
<p><a href="logout">Logout</a>
<% CsrfToken token = (CsrfToken) request.getAttribute(CsrfToken.class.getName()); %>
<form id="logout" method="post" action="logout">
<input type="hidden" name="<%= token.getParameterName() %>"
value="<%= token.getToken() %>"/>
</form>
<p><a href="#" onclick="document.forms[0].submit()">Logout</a></p>
</body>
</html>