org.apache.shiro.web.filter.authc.LogoutFilter Java Examples

The following examples show how to use org.apache.shiro.web.filter.authc.LogoutFilter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DefaultShiroWebModule.java    From opensoc-streaming with Apache License 2.0 5 votes vote down vote up
protected void configureShiroWeb() {
    bindConstant().annotatedWith(Names.named("shiro.loginUrl")).to( "/login.jsp" );
	bindRealm().to(CustomDomainADRealm.class);
	bind( LogoutFilter.class);
    
    addFilterChain("/login", ANON);
    addFilterChain("/logout", ANON);
    addFilterChain("/withsocket.jsp", AUTHC );
    addFilterChain("/withsocket2.jsp", ANON );
}
 
Example #2
Source File: WebSecurityModule.java    From seed with Mozilla Public License 2.0 5 votes vote down vote up
@Override
protected void configureShiroWeb() {
    for (WebSecurityConfig.UrlConfig urlConfig : securityConfig.getUrls()) {
        String pattern = urlConfig.getPattern();
        List<String> filters = urlConfig.getFilters();
        LOGGER.debug("URL pattern {} is secured with filter chain {}", pattern, filters);
        addFilterChain(pattern, getFilterKeys(filters));
    }

    // Bind filters which are not PatchMatchingFilters
    bind(LogoutFilter.class);

    // Bind custom filters not extending PathMatchingFilter as Shiro doesn't do it
    for (Class<? extends Filter> customFilter : customFilters) {
        if (!PathMatchingFilter.class.isAssignableFrom(customFilter)) {
            bind(customFilter);
        }
    }

    // General configuration attributes
    bindConstant().annotatedWith(Names.named("shiro.applicationName")).to(applicationName);
    bindConstant().annotatedWith(Names.named("shiro.loginUrl")).to(securityConfig.getLoginUrl());
    bindConstant().annotatedWith(Names.named("shiro.redirectUrl")).to(securityConfig.getLogoutUrl());
    bindConstant().annotatedWith(Names.named("shiro.successUrl")).to(securityConfig.getSuccessUrl());

    // Form configuration attributes
    WebSecurityConfig.FormConfig formConfig = securityConfig.form();
    bindConstant().annotatedWith(Names.named("shiro.usernameParam")).to(formConfig.getUsernameParameter());
    bindConstant().annotatedWith(Names.named("shiro.passwordParam")).to(formConfig.getPasswordParameter());
    bindConstant().annotatedWith(Names.named("shiro.rememberMeParam")).to(formConfig.getRememberMeParameter());
    bindConstant().annotatedWith(Names.named("shiro.failureAttribute")).to(formConfig.getFailureAttribute());

    // Shiro global configuration
    securityGuiceConfigurer.configure(binder());

    // Shiro filter
    bind(GuiceShiroFilter.class).in(Scopes.SINGLETON);
}
 
Example #3
Source File: ShiroConfig.java    From scaffold-cloud with MIT License 4 votes vote down vote up
@Bean
public ShiroFilterFactoryBean shiroFilter(DefaultWebSecurityManager securityManager) {
    ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean();
    shiroFilterFactoryBean.setSecurityManager(securityManager());

    Map<String, Filter> filters = new LinkedHashMap<>();
    LogoutFilter logoutFilter = new LogoutFilter();
    logoutFilter.setRedirectUrl("/home");
    shiroFilterFactoryBean.setFilters(filters);

    Map<String, String> filterChainDefinitionManager = new LinkedHashMap<String, String>();
    ResponseModel<List<SysMenuBO>> responseModel = sysMenuFeign.findAll();
    List<SysMenuBO> menuList = responseModel.getData();
    if (CollectionUtil.isNotEmpty(menuList)) {
        for (SysMenuBO menu : menuList) {
            if (StrUtil.isNotEmpty(menu.getUrl())) {
                ShiroService.formatUrl2Code(filterChainDefinitionManager, menu, PERMISSION_STRING);
            }
        }
    }
    filterChainDefinitionManager.put("/login", "anon");
    filterChainDefinitionManager.put("/logout", "logout");
    filterChainDefinitionManager.put("/login/check", "anon");
    filterChainDefinitionManager.put("/static/**", "anon");
    filterChainDefinitionManager.put("/notify/**", "anon");
    filterChainDefinitionManager.put("/lang/**", "anon");

    filterChainDefinitionManager.put("/*/login", "anon");
    filterChainDefinitionManager.put("/*/logout", "logout");
    filterChainDefinitionManager.put("/*/login/check", "anon");
    filterChainDefinitionManager.put("/*/static/**", "anon");
    filterChainDefinitionManager.put("/*/notify/**", "anon");
    filterChainDefinitionManager.put("/*/lang/**", "anon");

    filterChainDefinitionManager.put("/**", "anon");

    shiroFilterFactoryBean.setFilterChainDefinitionMap(filterChainDefinitionManager);

    shiroFilterFactoryBean.setLoginUrl("/login");
    shiroFilterFactoryBean.setSuccessUrl("/index");
    shiroFilterFactoryBean.setUnauthorizedUrl("/403");
    return shiroFilterFactoryBean;
}
 
Example #4
Source File: ShiroCasFilterFactoryBean.java    From shiro-cas-spring-boot-starter with Apache License 2.0 4 votes vote down vote up
protected boolean supports(Filter filter) {
	return filter instanceof AccessControlFilter ||  filter instanceof LogoutFilter;
}