-
Notifications
You must be signed in to change notification settings - Fork 19
Logout configuration
LELEU Jérôme edited this page Oct 8, 2020
·
9 revisions
You need to define a logout endpoint using the LogoutFilter
to handle logout.
>> Read the documentation to understand its behavior and the available options.
The default components are: JEESessionStore.INSTANCE
, JEEHttpActionAdapter.INSTANCE
, DefaultLogoutLogic.INSTANCE
and JEEContextFactory.INSTANCE
.
Notice that you may also use the configFactory
servlet parameter to define the security configuration.
The LogoutFilter
can be defined in the web.xml
file:
<filter>
<filter-name>logoutFilter</filter-name>
<filter-class>org.pac4j.j2e.filter.LogoutFilter</filter-class>
<init-param>
<param-name>defaultUrl</param-name>
<param-value>/urlAfterLogout</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>logoutFilter</filter-name>
<url-pattern>/logout</url-pattern>
</filter-mapping>
or using CDI and the org.pac4j.jee.util.FilterHelper
:
@Named
@ApplicationScoped
public class WebConfig {
@Inject
private Config config;
public void build(@Observes @Initialized(ApplicationScoped.class) ServletContext servletContext) {
final FilterHelper filterHelper = new FilterHelper(servletContext);
...
final LogoutFilter logoutFilter = new LogoutFilter(config, "/?defaulturlafterlogout");
logoutFilter.setDestroySession(true);
filterHelper.addFilterMapping("logoutFilter", logoutFilter, "/logout");
...
}
}