Skip to content

Commit

Permalink
Facebook OAuth related changes
Browse files Browse the repository at this point in the history
  • Loading branch information
naturalprogrammer committed Sep 26, 2019
1 parent c9651d5 commit 2560297
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 6 deletions.
6 changes: 3 additions & 3 deletions lemon-demo-jpa/src/main/resources/config/application-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ spring:
client:
provider:
facebook:
user-info-uri: https://graph.facebook.com/me?fields=email,name,verified
user-info-uri: https://graph.facebook.com/me?fields=email,name
registration:
google:
client-id: 1011974249454-6gq0hr01gqh3cndoqnss5r69tkk2nd84.apps.googleusercontent.com
client-secret: saDA6Cj60wipncFM-hzBD-C6
facebook:
client-id: 1234020186718741
client-secret: 0c0abaf685a83e879e8e48b1167c96ab
client-id: 548349525905412
client-secret: 15a20c560c4c780dabdc0e637c02087a

logging:
level:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ spring:
client:
provider:
facebook:
user-info-uri: https://graph.facebook.com/me?fields=email,name,verified
user-info-uri: https://graph.facebook.com/me?fields=email,name
registration:
google:
client-id: 1011974249454-6gq0hr01gqh3cndoqnss5r69tkk2nd84.apps.googleusercontent.com
client-secret: saDA6Cj60wipncFM-hzBD-C6
facebook:
client-id: 1234020186718741
client-secret: 0c0abaf685a83e879e8e48b1167c96ab
client-id: 548349525905412
client-secret: 15a20c560c4c780dabdc0e637c02087a

logging:
level:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,11 @@ public void fillAdditionalFields(String clientId, U user, Map<String, Object> at
*/
public boolean getOAuth2AccountVerified(String registrationId, Map<String, Object> attributes) {

// Facebook no more returns verified
// https://developers.facebook.com/docs/graph-api/reference/user
if ("facebook".equals(registrationId))
return true;

Object verified = attributes.get(StandardClaimNames.EMAIL_VERIFIED);
if (verified == null)
verified = attributes.get("verified");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import java.util.Collections;

import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.http.HttpCookie;
import org.springframework.http.ResponseCookie;
import org.springframework.http.server.reactive.ServerHttpResponse;
Expand All @@ -21,6 +23,8 @@

public class ReactiveCookieServerOAuth2AuthorizedClientRepository implements ServerOAuth2AuthorizedClientRepository {

private static final Log log = LogFactory.getLog(ReactiveCookieServerOAuth2AuthorizedClientRepository.class);

private int cookieExpirySecs;

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

log.debug("Loading authorized client for clientRegistrationId " + clientRegistrationId
+ ", principal " + principal + ", and exchange " + exchange);

return LecrUtils.fetchCookie(exchange, LecUtils.AUTHORIZATION_REQUEST_COOKIE_NAME)
.map(this::deserialize)
.orElse(Mono.empty());
Expand All @@ -41,6 +48,9 @@ public Mono<OAuth2AuthorizedClient> loadAuthorizedClient(String clientRegistrati
public Mono<Void> saveAuthorizedClient(OAuth2AuthorizedClient authorizedClient, Authentication principal,
ServerWebExchange exchange) {

log.debug("Saving authorized client " + authorizedClient
+ " for principal " + principal + ", and exchange " + exchange);

ServerHttpResponse response = exchange.getResponse();

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

log.debug("Deleting authorized client for clientRegistrationId " + clientRegistrationId
+ ", principal " + principal + ", and exchange " + exchange);

deleteCookies(exchange, LecUtils.AUTHORIZATION_REQUEST_COOKIE_NAME);
return Mono.empty();
}
Expand Down

0 comments on commit 2560297

Please sign in to comment.