Skip to content

Commit 2560297

Browse files
Facebook OAuth related changes
1 parent c9651d5 commit 2560297

File tree

4 files changed

+24
-6
lines changed

4 files changed

+24
-6
lines changed

lemon-demo-jpa/src/main/resources/config/application-dev.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ spring:
1616
client:
1717
provider:
1818
facebook:
19-
user-info-uri: https://graph.facebook.com/me?fields=email,name,verified
19+
user-info-uri: https://graph.facebook.com/me?fields=email,name
2020
registration:
2121
google:
2222
client-id: 1011974249454-6gq0hr01gqh3cndoqnss5r69tkk2nd84.apps.googleusercontent.com
2323
client-secret: saDA6Cj60wipncFM-hzBD-C6
2424
facebook:
25-
client-id: 1234020186718741
26-
client-secret: 0c0abaf685a83e879e8e48b1167c96ab
25+
client-id: 548349525905412
26+
client-secret: 15a20c560c4c780dabdc0e637c02087a
2727

2828
logging:
2929
level:

lemon-demo-reactive/src/main/resources/config/application-dev.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ spring:
1010
client:
1111
provider:
1212
facebook:
13-
user-info-uri: https://graph.facebook.com/me?fields=email,name,verified
13+
user-info-uri: https://graph.facebook.com/me?fields=email,name
1414
registration:
1515
google:
1616
client-id: 1011974249454-6gq0hr01gqh3cndoqnss5r69tkk2nd84.apps.googleusercontent.com
1717
client-secret: saDA6Cj60wipncFM-hzBD-C6
1818
facebook:
19-
client-id: 1234020186718741
20-
client-secret: 0c0abaf685a83e879e8e48b1167c96ab
19+
client-id: 548349525905412
20+
client-secret: 15a20c560c4c780dabdc0e637c02087a
2121

2222
logging:
2323
level:

spring-lemon-commons/src/main/java/com/naturalprogrammer/spring/lemon/commons/AbstractLemonService.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,11 @@ public void fillAdditionalFields(String clientId, U user, Map<String, Object> at
202202
*/
203203
public boolean getOAuth2AccountVerified(String registrationId, Map<String, Object> attributes) {
204204

205+
// Facebook no more returns verified
206+
// https://developers.facebook.com/docs/graph-api/reference/user
207+
if ("facebook".equals(registrationId))
208+
return true;
209+
205210
Object verified = attributes.get(StandardClaimNames.EMAIL_VERIFIED);
206211
if (verified == null)
207212
verified = attributes.get("verified");

spring-lemon-reactive/src/main/java/com/naturalprogrammer/spring/lemonreactive/security/ReactiveCookieServerOAuth2AuthorizedClientRepository.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import java.util.Collections;
44

55
import org.apache.commons.lang3.StringUtils;
6+
import org.apache.commons.logging.Log;
7+
import org.apache.commons.logging.LogFactory;
68
import org.springframework.http.HttpCookie;
79
import org.springframework.http.ResponseCookie;
810
import org.springframework.http.server.reactive.ServerHttpResponse;
@@ -21,6 +23,8 @@
2123

2224
public class ReactiveCookieServerOAuth2AuthorizedClientRepository implements ServerOAuth2AuthorizedClientRepository {
2325

26+
private static final Log log = LogFactory.getLog(ReactiveCookieServerOAuth2AuthorizedClientRepository.class);
27+
2428
private int cookieExpirySecs;
2529

2630
public ReactiveCookieServerOAuth2AuthorizedClientRepository(LemonProperties properties) {
@@ -32,6 +36,9 @@ public ReactiveCookieServerOAuth2AuthorizedClientRepository(LemonProperties prop
3236
public Mono<OAuth2AuthorizedClient> loadAuthorizedClient(String clientRegistrationId,
3337
Authentication principal, ServerWebExchange exchange) {
3438

39+
log.debug("Loading authorized client for clientRegistrationId " + clientRegistrationId
40+
+ ", principal " + principal + ", and exchange " + exchange);
41+
3542
return LecrUtils.fetchCookie(exchange, LecUtils.AUTHORIZATION_REQUEST_COOKIE_NAME)
3643
.map(this::deserialize)
3744
.orElse(Mono.empty());
@@ -41,6 +48,9 @@ public Mono<OAuth2AuthorizedClient> loadAuthorizedClient(String clientRegistrati
4148
public Mono<Void> saveAuthorizedClient(OAuth2AuthorizedClient authorizedClient, Authentication principal,
4249
ServerWebExchange exchange) {
4350

51+
log.debug("Saving authorized client " + authorizedClient
52+
+ " for principal " + principal + ", and exchange " + exchange);
53+
4454
ServerHttpResponse response = exchange.getResponse();
4555

4656
Assert.notNull(exchange, "exchange cannot be null");
@@ -81,6 +91,9 @@ public Mono<Void> saveAuthorizedClient(OAuth2AuthorizedClient authorizedClient,
8191
public Mono<Void> removeAuthorizedClient(String clientRegistrationId, Authentication principal,
8292
ServerWebExchange exchange) {
8393

94+
log.debug("Deleting authorized client for clientRegistrationId " + clientRegistrationId
95+
+ ", principal " + principal + ", and exchange " + exchange);
96+
8497
deleteCookies(exchange, LecUtils.AUTHORIZATION_REQUEST_COOKIE_NAME);
8598
return Mono.empty();
8699
}

0 commit comments

Comments
 (0)