Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CAS logout URL config in web.xml. #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions conf/example.yourdomain.edu/web.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@
<param-value>yourtomcatserver.yourdomain.edu</param-value><!-- name of the server to return to after successful authentication-->
</init-param>
</filter>
<filter>
<filter-name>CAS Logout Filter</filter-name>
<filter-class>ca.usask.ulc.filters.CasLogoutFilter</filter-class>
<init-param>
<param-name>ca.usask.ulc.filters.CasLogoutFilter.url</param-name>
<!-- Logout URL can take a service parameter that contains the url to redirect to after logout -->
<param-value>https://cas.usask.ca/cas/logout?service=https%3A%2F%2Fyourtomcatserver.yourdomain.ca</param-value>
</init-param>
</filter>
<filter>
<filter-name>Session Init Filter</filter-name>
<filter-class>ca.usask.ulc.filters.InitSessionFilter</filter-class>
Expand All @@ -44,6 +53,7 @@


<filter-mapping><filter-name>CAS Filter</filter-name><url-pattern>/auth/*</url-pattern> </filter-mapping>
<filter-mapping><filter-name>CAS Logout Filter</filter-name><url-pattern>/auth/logout</url-pattern> </filter-mapping>

<filter-mapping><filter-name>Session Init Filter</filter-name><url-pattern>/*</url-pattern> </filter-mapping>

Expand Down
60 changes: 60 additions & 0 deletions src/ca/usask/ulc/filters/CasLogoutFilter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package ca.usask.ulc.filters;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServletRequest;

import org.apache.log4j.Logger;


public final class CasLogoutFilter implements Filter
{
private FilterConfig filterConfig=null;

private static Logger logger = Logger.getLogger( CasLogoutFilter.class );


public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException
{
HttpServletRequest local=(HttpServletRequest)request;
HttpSession session=local.getSession(true);
// clear local session
session.removeAttribute("edu.yale.its.tp.cas.client.filter.user");

session.removeAttribute("userIsSysadmin");
session.removeAttribute("userHasAccessToOfferings");
session.removeAttribute("userHasAccessToOrganizations");
session.removeAttribute("userHasAccessToOrganizations");

session.removeAttribute("sessionInitialized");
session.removeAttribute("JSESSIONID");

// goto CAS logout url to clear CAS session
String url = filterConfig.
getInitParameter("ca.usask.ulc.filters.CasLogoutFilter.url");
HttpServletResponse httpResponse = (HttpServletResponse) response;
httpResponse.sendRedirect(url);
return;
}


public void destroy()
{
this.filterConfig=null;
}

public void init(FilterConfig filterConfig)
{
this.filterConfig=filterConfig;
}

}
6 changes: 0 additions & 6 deletions web/js/global_lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,12 +242,6 @@ function logout()
window.open("/cat/logout.jsp");
setTimeout('document.location="/cat/logout.jsp"',1000);
}
function updateLoginStatusAfterlogout()
{
window.location="/cat/auth/myCourses.jsp";
//window.location.reload();
//loadURLIntoId("/cat/login.jsp","#loginStatus");
}
function openEdit()
{
var text = "";
Expand Down
2 changes: 1 addition & 1 deletion web/login.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
String userid=(String)session.getAttribute("edu.yale.its.tp.cas.client.filter.user");
if (userid != null)
{
%>You are logged in as <%=userid%>. <a href="javascript:logout();">Log out</a>
%>You are logged in as <%=userid%>. <a href="/cat/auth/logout">Log out</a>
<%
}
else
Expand Down
40 changes: 0 additions & 40 deletions web/logout.jsp

This file was deleted.