|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2018 the original author or authors. |
| 2 | + * Copyright 2002-2019 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
64 | 64 | import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
|
65 | 65 | import org.springframework.security.web.util.matcher.NegatedRequestMatcher;
|
66 | 66 | import org.springframework.security.web.util.matcher.OrRequestMatcher;
|
| 67 | +import org.springframework.security.web.util.matcher.RequestHeaderRequestMatcher; |
67 | 68 | import org.springframework.security.web.util.matcher.RequestMatcher;
|
68 | 69 | import org.springframework.util.Assert;
|
69 | 70 | import org.springframework.util.ClassUtils;
|
@@ -604,8 +605,11 @@ private AuthenticationEntryPoint getLoginEntryPoint(B http, String providerLogin
|
604 | 605 | RequestMatcher defaultLoginPageMatcher = new AndRequestMatcher(
|
605 | 606 | new OrRequestMatcher(loginPageMatcher, faviconMatcher), defaultEntryPointMatcher);
|
606 | 607 |
|
| 608 | + RequestMatcher notXRequestedWith = new NegatedRequestMatcher( |
| 609 | + new RequestHeaderRequestMatcher("X-Requested-With", "XMLHttpRequest")); |
| 610 | + |
607 | 611 | LinkedHashMap<RequestMatcher, AuthenticationEntryPoint> entryPoints = new LinkedHashMap<>();
|
608 |
| - entryPoints.put(new NegatedRequestMatcher(defaultLoginPageMatcher), |
| 612 | + entryPoints.put(new AndRequestMatcher(notXRequestedWith, new NegatedRequestMatcher(defaultLoginPageMatcher)), |
609 | 613 | new LoginUrlAuthenticationEntryPoint(providerLoginPage));
|
610 | 614 |
|
611 | 615 | DelegatingAuthenticationEntryPoint loginEntryPoint = new DelegatingAuthenticationEntryPoint(entryPoints);
|
|
0 commit comments