smashraf24
smashraf24

Reputation: 11

Spring Security in single page app

I am new to the world of web development and my latest task requires me to use backbonesjs and requirejs on front end and spring boot on back end.I am supposed to have two pages one serving the login template and after its successful authentication I am supposed to show index.html which will show me username and password of logedin user.I am able to submitt loginform using ajax in my loginview and on its authentication I want to serve the index1.html.But when i do windows.location.href to serve index.html nothing happens.I guess spring security is redirecting to he same page again.How can I achieve that.

Upvotes: 0

Views: 1092

Answers (1)

Serkan Algül
Serkan Algül

Reputation: 93

maybe this is help for you.

Spring 3 with No xml.

I have two pages. These are login and index jsp.

  • Spring WebSecurityConfiguerer configure method like this. @Override protected void configure( HttpSecurity http ) throws Exception{ http.exceptionHandling(). accessDeniedPage( "/login?accessDeniedError=1").and(). authorizeRequests().anyRequest().authenticated().and(). formLogin().loginPage( "/login" ). defaultSuccessUrl( "/index", true ). failureUrl( "/login?authenticationFailure" ).permitAll().and(). logout().deleteCookies( "JSESSIONID" ). invalidateHttpSession( true).permitAll(); }
  • Spring Mvc Controller's methods is : @RequestMapping(value = "/login", method = RequestMethod.GET) public String login( ModelMap model, HttpServletRequest request ){ //business logic return "login"; } @RequestMapping(value = "/index", method = RequestMethod.GET) public String index( ModelMap model, Principal principal, HttpServletRequest request ){ //business logic return "index"; }

Upvotes: 1

Related Questions