use of org.springframework.security.web.AuthenticationEntryPoint in project spring-security by spring-projects.
the class DefaultLoginPageConfigurer method configure.
@Override
@SuppressWarnings("unchecked")
public void configure(H http) {
AuthenticationEntryPoint authenticationEntryPoint = null;
ExceptionHandlingConfigurer<?> exceptionConf = http.getConfigurer(ExceptionHandlingConfigurer.class);
if (exceptionConf != null) {
authenticationEntryPoint = exceptionConf.getAuthenticationEntryPoint();
}
if (this.loginPageGeneratingFilter.isEnabled() && authenticationEntryPoint == null) {
this.loginPageGeneratingFilter = postProcess(this.loginPageGeneratingFilter);
http.addFilter(this.loginPageGeneratingFilter);
LogoutConfigurer<H> logoutConfigurer = http.getConfigurer(LogoutConfigurer.class);
if (logoutConfigurer != null) {
http.addFilter(this.logoutPageGeneratingFilter);
}
}
}
use of org.springframework.security.web.AuthenticationEntryPoint in project spring-security by spring-projects.
the class MiscHttpConfigTests method requestWhenCustomHttpBasicEntryPointRefThenInvokesOnCommence.
@Test
public void requestWhenCustomHttpBasicEntryPointRefThenInvokesOnCommence() throws Exception {
this.spring.configLocations(xml("CustomHttpBasicEntryPointRef")).autowire();
AuthenticationEntryPoint entryPoint = this.spring.getContext().getBean(AuthenticationEntryPoint.class);
// @formatter:off
this.mvc.perform(get("/protected")).andExpect(status().isOk());
// @formatter:on
verify(entryPoint).commence(any(HttpServletRequest.class), any(HttpServletResponse.class), any(AuthenticationException.class));
}
use of org.springframework.security.web.AuthenticationEntryPoint in project pivotal-cla by pivotalsoftware.
the class SecurityConfig method configure.
@Override
protected void configure(HttpSecurity http) throws Exception {
AuthenticationEntryPoint entryPoint = entryPoint();
AdminRequestedAccessDeniedHandler accessDeniedHandler = new AdminRequestedAccessDeniedHandler(entryPoint);
http.requiresChannel().requestMatchers(request -> request.getHeader("x-forwarded-port") != null).requiresSecure().and().exceptionHandling().authenticationEntryPoint(entryPoint).accessDeniedHandler(accessDeniedHandler).and().csrf().ignoringAntMatchers("/github/hooks/**").and().authorizeRequests().requestMatchers(CorsUtils::isPreFlightRequest).permitAll().mvcMatchers("/login/**", "/", "/about", "/faq").permitAll().mvcMatchers("/view/**").permitAll().mvcMatchers("/webjars/**", "/assets/**").permitAll().mvcMatchers("/github/hooks/**").permitAll().mvcMatchers("/admin", "/admin/cla/link/**", "/admin/help/**").hasRole("ADMIN").mvcMatchers("/admin/**", "/manage/**").hasRole("CLA_AUTHOR").anyRequest().authenticated().and().logout().logoutSuccessUrl("/?logout");
}
use of org.springframework.security.web.AuthenticationEntryPoint in project pivotal-cla by pivotalsoftware.
the class SecurityConfig method entryPoint.
private AuthenticationEntryPoint entryPoint() {
LinkedHashMap<RequestMatcher, AuthenticationEntryPoint> entryPoints = new LinkedHashMap<>();
entryPoints.put(new AntPathRequestMatcher("/github/hooks/**"), new HttpStatusEntryPoint(HttpStatus.UNAUTHORIZED));
entryPoints.put(new AntPathRequestMatcher("/admin/**"), new GitHubAuthenticationEntryPoint(oauthConfig.getMain(), "user:email,repo:status,admin:repo_hook,admin:org_hook,read:org"));
BasicAuthenticationEntryPoint basicEntryPoint = new BasicAuthenticationEntryPoint();
basicEntryPoint.setRealmName("Pivotal CLA");
entryPoints.put(new AntPathRequestMatcher("/manage/**"), basicEntryPoint);
DelegatingAuthenticationEntryPoint entryPoint = new DelegatingAuthenticationEntryPoint(entryPoints);
entryPoint.setDefaultEntryPoint(new GitHubAuthenticationEntryPoint(oauthConfig.getMain(), "user:email"));
return entryPoint;
}
use of org.springframework.security.web.AuthenticationEntryPoint in project spring-security by spring-projects.
the class DelegatingAuthenticationEntryPointTests method testFirstEntryPoint.
@Test
public void testFirstEntryPoint() throws Exception {
AuthenticationEntryPoint firstAEP = mock(AuthenticationEntryPoint.class);
RequestMatcher firstRM = mock(RequestMatcher.class);
AuthenticationEntryPoint secondAEP = mock(AuthenticationEntryPoint.class);
RequestMatcher secondRM = mock(RequestMatcher.class);
given(firstRM.matches(this.request)).willReturn(true);
this.entryPoints.put(firstRM, firstAEP);
this.entryPoints.put(secondRM, secondAEP);
this.daep.commence(this.request, null, null);
verify(firstAEP).commence(this.request, null, null);
verify(secondAEP, never()).commence(this.request, null, null);
verify(this.defaultEntryPoint, never()).commence(this.request, null, null);
verify(secondRM, never()).matches(this.request);
}
Aggregations