logout - Unable to redirect to CAS for single log out from spring -


i developing application has angular2 frontend , spring boot backend. authentication using cas. single sign on working properly, single log out not working , not redirecting cas/logout endpoint.(i sending post spring boot app's /logout url angular app )

cas version - 4.2.2

cas client core - 3.4

i followed http://docs.spring.io/spring-security/site/migrate/current/3-to-4/html5/migrate-3-to-4-jc.html#m3to4-filter-urls-cas , did necessary changes authentication filter , logout filter. still couldn't identify issue. appreciated.

security config

@configuration @enableglobalmethodsecurity(prepostenabled = true, jsr250enabled = true) @enablewebsecurity public class securityconfiguration extends websecurityconfigureradapter {       @autowired     private authproperties properties;     @override     protected void configure(httpsecurity http) throws exception {          http             .addfilterafter(csrfheaderfilter(), csrffilter.class)             .addfilterbefore(requestsinglelogoutfilter(), logoutfilter.class)             .addfilterbefore(singlesignoutfilter(), casauthenticationfilter.class)             .addfilterbefore(casauthenticationfilter(), basicauthenticationfilter.class)             .exceptionhandling()             .authenticationentrypoint(casauthenticationentrypoint())         .and()             .logout()                 .logouturl("/logout")                 .invalidatehttpsession(true)                 .deletecookies("jsessionid")                 .permitall()         .and()             .authorizerequests()                 .antmatchers("//**").authenticated()                 .antmatchers("/test").permitall()         .and()             .csrf()                 .csrftokenrepository(csrftokenrepository());     }      /***      * service properties refer application being authenticated      * typically in case, service authentication engine or auth app      */     @bean     public serviceproperties serviceproperties() {         serviceproperties sp = new serviceproperties();         sp.setservice(properties.getappservicesecurity());         sp.setartifactparameter("casticket");         sp.setauthenticateallartifacts(true);         sp.setsendrenew(false);         return sp;     }     @bean     public casauthenticationprovider casauthenticationprovider() throws exception {         casauthenticationprovider casauthenticationprovider = new casauthenticationprovider();         casauthenticationprovider.setauthenticationuserdetailsservice(userservice());         casauthenticationprovider.setserviceproperties(serviceproperties());         if (properties.iscasproxyticket()) {             casauthenticationprovider.setticketvalidator(cas30serviceproxyticketvalidator());             casauthenticationprovider.setstatelessticketcache(ehmanager());         } else {             casauthenticationprovider.setticketvalidator(cas30serviceticketvalidator());         }          casauthenticationprovider.setkey(properties.getproviderkey());         return casauthenticationprovider;     }      @bean     public sessionauthenticationstrategy sessionstrategy() {         sessionauthenticationstrategy sessionstrategy = new sessionfixationprotectionstrategy();         return sessionstrategy;     }      @bean     public cas30serviceticketvalidator cas30serviceticketvalidator() {         return new cas30serviceticketvalidator(properties.getcasurlprefix());     }      @bean     public casauthenticationfilter casauthenticationfilter() throws exception {         casauthenticationfilter casauthenticationfilter = new casauthenticationfilter();         casauthenticationfilter.setauthenticationmanager(authenticationmanager());         casauthenticationfilter.setsessionauthenticationstrategy(sessionstrategy());         casauthenticationfilter.setproxygrantingticketstorage(pgtstorage());         casauthenticationfilter.setfilterprocessesurl("/login/cas");         casauthenticationfilter.setproxyreceptorurl(properties.getcasproxyreceptor());         return casauthenticationfilter;     }      @bean     public casauthenticationentrypoint casauthenticationentrypoint() {         casauthenticationentrypoint casauthenticationentrypoint = new tbxcasauthenticationentrypoint();         casauthenticationentrypoint.setloginurl(properties.getcasloginurl());         casauthenticationentrypoint.setserviceproperties(serviceproperties());         return casauthenticationentrypoint;     }       @bean     public logoutfilter requestsinglelogoutfilter() {         stringbuffer stringbuffer = new stringbuffer("");         stringbuffer.append(properties.getcaslogouturl());         logoutfilter logoutfilter = new logoutfilter("https://localhost:9443/cas/logout", new securitycontextlogouthandler());//env.getrequiredproperty(cas_url_logout) + "?service="+ env.getrequiredproperty(app_service_home)         logoutfilter.setfilterprocessesurl("/logout");         return logoutfilter;     }      @bean     public singlesignoutfilter singlesignoutfilter() {         singlesignoutfilter filter = new singlesignoutfilter();         filter.setartifactparametername(protocol.cas3.getartifactparametername());         filter.setcasserverurlprefix("https://localhost:9443/cas");         filter.setignoreinitconfiguration(true);         return filter;     }       @bean     public filter csrfheaderfilter() {         return new onceperrequestfilter() {             @override             protected void dofilterinternal(httpservletrequest request, httpservletresponse response, filterchain filterchain) throws servletexception, ioexception {                 csrftoken csrf = (csrftoken) request.getattribute(csrftoken.class.getname());                 if (csrf != null) {                     cookie cookie = webutils.getcookie(request, "xsrf-token");                     if (cookie != null) {                     } else {                     }                     string token = csrf.gettoken();                     if (cookie == null || token != null && !token.equals(cookie.getvalue())) {                         cookie = new cookie("xsrf-token", token);                         cookie.setpath("/");                         response.addcookie(cookie);                     }                 }                 filterchain.dofilter(request, response);             }         };     }      @bean     public csrftokenrepository csrftokenrepository() {         httpsessioncsrftokenrepository repository = new httpsessioncsrftokenrepository();         repository.setheadername("x-xsrf-token");         return repository;     }        /**      * configure via websecurity provides fonts, images, scripts, styles , views removed      * security features, because, access these scripts must regarding user experience      **/     @override     public void configure(websecurity web) throws exception {         web.ignoring()                 .antmatchers("/fonts*//**")                 .antmatchers("/images1*//**")                 .antmatchers("/scripts*//**")                 .antmatchers("/styles*//**")                 .antmatchers("/views*//**")                 .antmatchers("/i18n*//**");     }     @bean     public userprinciplehandler userservice() {         userprinciplehandler userprincipleservicehanlder = new userprinciplehandler();         return userprincipleservicehanlder;     }      @bean     public requestcontextlistener requestcontextlistener() {         return new requestcontextlistener();     }      @bean     public requestcontextfilter requestcontextfilter() {         return new requestcontextfilter();     }      @bean     public serviceauthenticationdetailssource serviceauthenticationdatasource() {         serviceauthenticationdetailssource servicedetailsource = new serviceauthenticationdetailssource(serviceproperties());         return servicedetailsource;     }      @bean     public simpleurlauthenticationfailurehandler simpleurlauthentication() {         simpleurlauthenticationfailurehandler failurehandler = new simpleurlauthenticationfailurehandler();         failurehandler.setdefaultfailureurl(properties.getcasfailureurl());         return failurehandler;     }      @bean     public proxylist proxychainlist() {         list<string> list = properties.getproxylist();         string[] stringarray = arrays.copyof(list.toarray(), list.size(), string[].class);         list<string[]> urls = new arraylist<string[]>();         urls.add(stringarray);         proxylist proxylist = new proxylist(urls);         return proxylist;     }       @bean     public proxygrantingticketstorageimpl pgtstorage() {         proxygrantingticketstorageimpl pgtimpl = new proxygrantingticketstorageimpl();         return pgtimpl;     }      @bean     public springcachebasedticketcache ehmanager() throws exception {         springcachebasedticketcache ehmanager = new springcachebasedticketcache(cachemap());         return ehmanager;     }      @bean     public concurrentmapcache cachemap() {         concurrentmapcache concachemap = new concurrentmapcache("castickets");         concachemap.put("castickets", 50);         return concachemap;     }     @bean     public cas30proxyticketvalidator cas30serviceproxyticketvalidator() {          cas30proxyticketvalidator validator = new cas30proxyticketvalidator(properties.getcasurlprefix());//env.getrequiredproperty(cas_url_prefix)         stringbuffer stringbuffer = new stringbuffer("");         stringbuffer.append(properties.getappservicehome()).append(properties.getcasproxyreceptor());         validator.setproxycallbackurl(stringbuffer.tostring());//env.getrequiredproperty(app_service_home)+"login/cas/proxyreceptor"         validator.setproxygrantingticketstorage(pgtstorage());         validator.setallowedproxychains(proxychainlist());         validator.setacceptanyproxy(false);          return validator;     }  } 


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -