|
4 | 4 | import com.nimbusds.oauth2.sdk.util.StringUtils;
|
5 | 5 | import org.springframework.security.oauth2.client.web.AuthorizationRequestRepository;
|
6 | 6 | import org.springframework.security.oauth2.core.endpoint.OAuth2AuthorizationRequest;
|
| 7 | +import org.springframework.stereotype.Component; |
| 8 | + |
7 | 9 | import javax.servlet.http.HttpServletRequest;
|
8 | 10 | import javax.servlet.http.HttpServletResponse;
|
9 | 11 |
|
| 12 | +@Component |
10 | 13 | public class HttpCookieOAuth2AuthorizationRequestRepository implements AuthorizationRequestRepository<OAuth2AuthorizationRequest> {
|
11 | 14 | public static final String OAUTH2_AUTHORIZATION_REQUEST_COOKIE_NAME = "oauth2_auth_request";
|
12 | 15 | public static final String REDIRECT_URI_PARAM_COOKIE_NAME = "redirect_uri";
|
@@ -36,19 +39,11 @@ public void saveAuthorizationRequest(OAuth2AuthorizationRequest authorizationReq
|
36 | 39 |
|
37 | 40 | @Override
|
38 | 41 | public OAuth2AuthorizationRequest removeAuthorizationRequest(HttpServletRequest request) {
|
39 |
| - /* |
40 |
| - Ideally, the saved OAuth2AuthorizationRequest should be removed in this method. |
41 |
| -
|
42 |
| - Since we're saving the OAuth2AuthorizationRequest in cookies, we need access to the HttpServletResponse to clear them. |
43 |
| - But that is not passed to this method. |
44 |
| -
|
45 |
| - Therefore, We'll clear the cookies in OAuth2AuthenticationSuccessHandler instead. |
46 |
| - */ |
47 |
| - return loadAuthorizationRequest(request); |
| 42 | + return this.loadAuthorizationRequest(request); |
48 | 43 | }
|
49 | 44 |
|
50 |
| - public static void removeAuthorizationRequest(HttpServletRequest request, HttpServletResponse response) { |
51 |
| - CookieUtils.deleteCookie(request, response, OAUTH2_AUTHORIZATION_REQUEST_COOKIE_NAME); |
52 |
| - CookieUtils.deleteCookie(request, response, REDIRECT_URI_PARAM_COOKIE_NAME); |
| 45 | + @Override |
| 46 | + public OAuth2AuthorizationRequest removeAuthorizationRequest(HttpServletRequest request, HttpServletResponse response) { |
| 47 | + return this.loadAuthorizationRequest(request); |
53 | 48 | }
|
54 | 49 | }
|
0 commit comments