这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@
import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.web.SecurityFilterChain;
import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler;
import org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
import org.springframework.security.web.context.HttpSessionSecurityContextRepository;

@EnableWebSecurity
@PropertySource("classpath:/application-extrafields.properties")
Expand Down Expand Up @@ -56,6 +58,8 @@ public CustomAuthenticationFilter authenticationFilter(AuthenticationManager aut
CustomAuthenticationFilter filter = new CustomAuthenticationFilter();
filter.setAuthenticationManager(authenticationManager);
filter.setAuthenticationFailureHandler(failureHandler());
filter.setAuthenticationSuccessHandler(new SavedRequestAwareAuthenticationSuccessHandler());
filter.setSecurityContextRepository(new HttpSessionSecurityContextRepository());
return filter;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer;
import org.springframework.security.web.SecurityFilterChain;
import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler;
import org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
import org.springframework.security.web.context.HttpSessionSecurityContextRepository;

@EnableWebSecurity
@PropertySource("classpath:/application-extrafields.properties")
Expand Down Expand Up @@ -46,6 +48,8 @@ public SimpleAuthenticationFilter authenticationFilter(AuthenticationManager aut
SimpleAuthenticationFilter filter = new SimpleAuthenticationFilter();
filter.setAuthenticationManager(authenticationManager);
filter.setAuthenticationFailureHandler(failureHandler());
filter.setAuthenticationSuccessHandler(new SavedRequestAwareAuthenticationSuccessHandler());
filter.setSecurityContextRepository(new HttpSessionSecurityContextRepository());
return filter;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void givenAccessSecuredResource_whenAuthenticated_thenAuthHasExtraFields(
.session(session)
.with(csrf()))
.andExpect(status().is3xxRedirection())
.andExpect(redirectedUrlPattern("**/user/index"))
.andExpect(redirectedUrlPattern("**/user/index?continue"))
.andReturn();

mockMvc.perform(securedResourceAccess.session(session))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void givenAccessSecuredResource_whenAuthenticated_thenAuthHasExtraFields(
.session(session)
.with(csrf()))
.andExpect(status().is3xxRedirection())
.andExpect(redirectedUrlPattern("**/user/index"))
.andExpect(redirectedUrlPattern("**/user/index?continue"))
.andReturn();

mockMvc.perform(securedResourceAccess.session(session))
Expand Down