Spring security change permitAll list of URLs at runtime -
i need change spring security configuration @ runtime use-case need maintain xml contains vanity urls , corresponding urls. need tell spring @ runtime urls newly added xml , not block access public urls.
my start configuration looks this.
public static string[] permit_all_urls = new string[] { "/css/**", "/js/**", "/images/**", "/healthcheck.jsp", "/healthcheck", "/healthcheck.xml", "/memberlogin.html", "/login.html","/wro/**","/*home.html", "/home.html","/auctions.html","/*auctions.html", "/upgrade-subscription", "/pages/**","/public/**", "/", "/content/**","/cms/content/**","/salelistresultallframe/**"}; @override protected void configure(httpsecurity http) throws exception { list<string> permitallurls = new arraylist<>(arrays.aslist(permit_all_urls)); if (configdatamanager.getallredirecturlsmap() != null) { permitallurls.addall(configdatamanager.getallredirecturlsmap().keyset()); } string[] publicurlpatterns = permitallurls.toarray(new string[permitallurls.size()]); _logger.info("loading spring security configurations - public urls - " + publicurlpatterns); copartauthenticationsuccesshandler.setdefaulttargeturl("/dologin.html"); http.exceptionhandling().authenticationentrypoint(copartauthenticationentrypoint); http.csrf().disable().headers().disable().sessionmanagement().sessionfixation().none(); http.addfilterafter(new resttimoutredirectfilter(), exceptiontranslationfilter.class) .addfilterafter(copartpreauthenticationfilter, abstractpreauthenticatedprocessingfilter.class) .addfilterbefore(membersitecodefilter, anonymousauthenticationfilter.class) .addfilterbefore(membersitecodefilter, abstractpreauthenticatedprocessingfilter.class) .anonymous().authenticationfilter(new copartanonymousauthenticationfilter()); http.authorizerequests().antmatchers(loginurl).access("isanonymous() or isauthenticated()") .antmatchers(publicurlpatterns).permitall().anyrequest().fullyauthenticated().and() .formlogin().loginprocessingurl(loginurl).loginpage(loginpage).permitall().usernameparameter("username") .passwordparameter("password").successhandler(copartauthenticationsuccesshandler) .failureurl("/dologin.html?result=error&error=authfailure").permitall().and().logout() .logouturl("/logout").invalidatehttpsession(true).logoutsuccessurl("/dologout.html?result=success") .deletecookies(constants.auction_cookie).permitall(); http.portmapper().http(http_port).mapsto(https_port).http(http_port1).mapsto(https_port1); }
i need way reconfigure spring security every time vanity url xml changes.
Comments
Post a Comment