Skip to content

Update SpringSecurity.java#6

Open
Kappa97 wants to merge 1 commit intoRameshMF:masterfrom
Kappa97:patch-1
Open

Update SpringSecurity.java#6
Kappa97 wants to merge 1 commit intoRameshMF:masterfrom
Kappa97:patch-1

Conversation

@Kappa97
Copy link

@Kappa97 Kappa97 commented Dec 28, 2022

--fix for first log in

--fix for first log in
@DAVIDSS79
Copy link

HttpSessionRequestCache requestCache = new HttpSessionRequestCache();
requestCache.setMatchingRequestParameterName("continue");

    http.csrf().disable()
            .authorizeHttpRequests((authorize) ->
                    authorize.requestMatchers("/register/**").permitAll()
                            .requestMatchers("/index").permitAll()
                            .requestMatchers("/users").hasRole("ADMIN")
            ).formLogin(
                    form -> form
                            .loginPage("/login")
                            .loginProcessingUrl("/login")
                            .defaultSuccessUrl("/users") 
                            .defaultSuccessUrl("/users", true)                                
                            .permitAll()
            ).logout(
                    logout -> logout
                            .logoutRequestMatcher(new AntPathRequestMatcher("/logout"))
                            .permitAll()
            ).requestCache((cache) -> cache
            .requestCache(requestCache)
            );        
    return http.build();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants