Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 38afdde

Browse files
Cleanup
1 parent 378b4b8 commit 38afdde

File tree

3 files changed

+6
-12
lines changed

3 files changed

+6
-12
lines changed

‎spring-social/src/main/java/com/example/springsocial/config/SecurityConfig.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import com.example.springsocial.security.oauth2.CustomOAuth2UserService;
55
import com.example.springsocial.security.oauth2.HttpCookieOAuth2AuthorizationRequestRepository;
66
import com.example.springsocial.security.oauth2.OAuth2AuthenticationFailureHandler;
7-
import com.example.springsocial.security.oauth2.Oauth2AuthenticationSuccessHandler;
7+
import com.example.springsocial.security.oauth2.OAuth2AuthenticationSuccessHandler;
88
import org.springframework.beans.factory.annotation.Autowired;
99
import org.springframework.context.annotation.Bean;
1010
import org.springframework.context.annotation.Configuration;
@@ -38,7 +38,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
3838
private CustomOAuth2UserService customOAuth2UserService;
3939

4040
@Autowired
41-
private Oauth2AuthenticationSuccessHandler oauth2AuthenticationSuccessHandler;
41+
private OAuth2AuthenticationSuccessHandler oauth2AuthenticationSuccessHandler;
4242

4343
@Autowired
4444
private OAuth2AuthenticationFailureHandler oAuth2AuthenticationFailureHandler;

‎spring-social/src/main/java/com/example/springsocial/security/oauth2/HttpCookieOAuth2AuthorizationRequestRepository.java‎

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,23 @@
44
import com.nimbusds.oauth2.sdk.util.StringUtils;
55
import org.springframework.security.oauth2.client.web.AuthorizationRequestRepository;
66
import org.springframework.security.oauth2.core.endpoint.OAuth2AuthorizationRequest;
7-
import org.springframework.util.Assert;
87
import javax.servlet.http.HttpServletRequest;
98
import javax.servlet.http.HttpServletResponse;
109

1110
public class HttpCookieOAuth2AuthorizationRequestRepository implements AuthorizationRequestRepository<OAuth2AuthorizationRequest> {
1211
public static final String OAUTH2_AUTHORIZATION_REQUEST_COOKIE_NAME = "oauth2_auth_request";
1312
public static final String REDIRECT_URI_PARAM_COOKIE_NAME = "redirect_uri";
14-
private static final int cookieExpireSeconds = 120;
13+
private static final int cookieExpireSeconds = 180;
1514

1615
@Override
1716
public OAuth2AuthorizationRequest loadAuthorizationRequest(HttpServletRequest request) {
18-
Assert.notNull(request, "request cannot be null");
1917
return CookieUtils.getCookie(request, OAUTH2_AUTHORIZATION_REQUEST_COOKIE_NAME)
2018
.map(cookie -> CookieUtils.deserialize(cookie, OAuth2AuthorizationRequest.class))
2119
.orElse(null);
2220
}
2321

2422
@Override
2523
public void saveAuthorizationRequest(OAuth2AuthorizationRequest authorizationRequest, HttpServletRequest request, HttpServletResponse response) {
26-
Assert.notNull(request, "request cannot be null");
27-
Assert.notNull(response, "response cannot be null");
28-
2924
if (authorizationRequest == null) {
3025
CookieUtils.deleteCookie(request, response, OAUTH2_AUTHORIZATION_REQUEST_COOKIE_NAME);
3126
CookieUtils.deleteCookie(request, response, REDIRECT_URI_PARAM_COOKIE_NAME);
@@ -41,14 +36,13 @@ public void saveAuthorizationRequest(OAuth2AuthorizationRequest authorizationReq
4136

4237
@Override
4338
public OAuth2AuthorizationRequest removeAuthorizationRequest(HttpServletRequest request) {
44-
Assert.notNull(request, "request cannot be null");
4539
/*
4640
Ideally, the saved OAuth2AuthorizationRequest should be removed in this method.
4741
4842
Since we're saving the OAuth2AuthorizationRequest in cookies, we need access to the HttpServletResponse to clear them.
4943
But that is not passed to this method.
5044
51-
Therefore, We'll clear the cookies in Oauth2AuthenticationSuccessHandler instead.
45+
Therefore, We'll clear the cookies in OAuth2AuthenticationSuccessHandler instead.
5246
*/
5347
return loadAuthorizationRequest(request);
5448
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@
2020
import static com.example.springsocial.security.oauth2.HttpCookieOAuth2AuthorizationRequestRepository.REDIRECT_URI_PARAM_COOKIE_NAME;
2121

2222
@Component
23-
public class Oauth2AuthenticationSuccessHandler extends SimpleUrlAuthenticationSuccessHandler {
23+
public class OAuth2AuthenticationSuccessHandler extends SimpleUrlAuthenticationSuccessHandler {
2424

2525
private TokenProvider tokenProvider;
2626

2727
private AppProperties appProperties;
2828

2929
@Autowired
30-
Oauth2AuthenticationSuccessHandler(TokenProvider tokenProvider, AppProperties appProperties) {
30+
OAuth2AuthenticationSuccessHandler(TokenProvider tokenProvider, AppProperties appProperties) {
3131
this.tokenProvider = tokenProvider;
3232
this.appProperties = appProperties;
3333
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /