From 4e01d83d60c577908f59a161aea395e2bb36b99a Mon Sep 17 00:00:00 2001 From: Brice Lenfant Date: Wed, 29 Nov 2017 21:00:02 +0200 Subject: [PATCH 1/7] Fix dual authentication problem. --- .../RestfulAuthenticationCookie.class.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/plugins/authentication/RestfulAuthenticationCookie.class.php b/plugins/authentication/RestfulAuthenticationCookie.class.php index da52694d..08fdc238 100644 --- a/plugins/authentication/RestfulAuthenticationCookie.class.php +++ b/plugins/authentication/RestfulAuthenticationCookie.class.php @@ -6,6 +6,20 @@ class RestfulAuthenticationCookie extends RestfulAuthenticationBase implements RestfulAuthenticationInterface { + /** + * {@inheritdoc} + */ + public function applies(array $request = array(), $method = \RestfulInterface::GET) { + if (variable_get('restful_prefer_access_token', FALSE) && $request['__application']['access_token']) { + // Skip cookies auth. The variable may be set if you want to be logged in + // both with a session cookie and with an access token, favoriting the + // access_token. + // request. see https://github.com/RESTful-Drupal/restful/issues/412. + return; + } + return TRUE; + } + /** * Implements RestfulAuthenticationInterface::authenticate(). */ From bd8203ca852cc242d0cd76b3817ed49579f8b1dc Mon Sep 17 00:00:00 2001 From: Brice Lenfant Date: Wed, 29 Nov 2017 21:03:44 +0200 Subject: [PATCH 2/7] Better comments. --- .../authentication/RestfulAuthenticationCookie.class.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/plugins/authentication/RestfulAuthenticationCookie.class.php b/plugins/authentication/RestfulAuthenticationCookie.class.php index 08fdc238..0de0d54b 100644 --- a/plugins/authentication/RestfulAuthenticationCookie.class.php +++ b/plugins/authentication/RestfulAuthenticationCookie.class.php @@ -10,11 +10,12 @@ class RestfulAuthenticationCookie extends RestfulAuthenticationBase implements R * {@inheritdoc} */ public function applies(array $request = array(), $method = \RestfulInterface::GET) { + + // Skip cookies auth if we have an access token. if (variable_get('restful_prefer_access_token', FALSE) && $request['__application']['access_token']) { - // Skip cookies auth. The variable may be set if you want to be logged in - // both with a session cookie and with an access token, favoriting the - // access_token. - // request. see https://github.com/RESTful-Drupal/restful/issues/412. + // The variable may be set if you want to be logged in both with a session + // cookie and with an access token, favoriting the access_token request + // see https://github.com/RESTful-Drupal/restful/issues/412. return; } return TRUE; From 6fbd7e0e1946a492275767ed0ddc62bf8d2817b7 Mon Sep 17 00:00:00 2001 From: Brice Lenfant Date: Wed, 29 Nov 2017 21:13:19 +0200 Subject: [PATCH 3/7] retry tests. --- plugins/authentication/RestfulAuthenticationCookie.class.php | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/authentication/RestfulAuthenticationCookie.class.php b/plugins/authentication/RestfulAuthenticationCookie.class.php index 0de0d54b..ec4ed95c 100644 --- a/plugins/authentication/RestfulAuthenticationCookie.class.php +++ b/plugins/authentication/RestfulAuthenticationCookie.class.php @@ -10,7 +10,6 @@ class RestfulAuthenticationCookie extends RestfulAuthenticationBase implements R * {@inheritdoc} */ public function applies(array $request = array(), $method = \RestfulInterface::GET) { - // Skip cookies auth if we have an access token. if (variable_get('restful_prefer_access_token', FALSE) && $request['__application']['access_token']) { // The variable may be set if you want to be logged in both with a session From 5c92cd0dfda4839678aa6360f6158adb3049b73f Mon Sep 17 00:00:00 2001 From: Brice Lenfant Date: Wed, 29 Nov 2017 21:17:47 +0200 Subject: [PATCH 4/7] Drush 8 for travis. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 8ad30316..fb9ff692 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,7 +16,7 @@ mysql: install: # Grab Drush - - composer global require "drush/drush:7.*" + - composer global require "drush/drush:8.*" - phpenv rehash # Make sure we don't fail when checking out projects - echo -e "Host github.com\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config From 504573cc269773e4203a8fefbf3ac6a23c3070c9 Mon Sep 17 00:00:00 2001 From: Brice Lenfant Date: Thu, 30 Nov 2017 10:19:41 +0200 Subject: [PATCH 5/7] Restore Drush version. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index fb9ff692..8ad30316 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,7 +16,7 @@ mysql: install: # Grab Drush - - composer global require "drush/drush:8.*" + - composer global require "drush/drush:7.*" - phpenv rehash # Make sure we don't fail when checking out projects - echo -e "Host github.com\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config From 182ec8af0460b46b4979d82f831d21f81d8caa30 Mon Sep 17 00:00:00 2001 From: Brice Lenfant Date: Mon, 4 Dec 2017 11:34:43 +0200 Subject: [PATCH 6/7] Fix warning. --- plugins/authentication/RestfulAuthenticationCookie.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/authentication/RestfulAuthenticationCookie.class.php b/plugins/authentication/RestfulAuthenticationCookie.class.php index ec4ed95c..829ddea1 100644 --- a/plugins/authentication/RestfulAuthenticationCookie.class.php +++ b/plugins/authentication/RestfulAuthenticationCookie.class.php @@ -11,7 +11,7 @@ class RestfulAuthenticationCookie extends RestfulAuthenticationBase implements R */ public function applies(array $request = array(), $method = \RestfulInterface::GET) { // Skip cookies auth if we have an access token. - if (variable_get('restful_prefer_access_token', FALSE) && $request['__application']['access_token']) { + if (variable_get('restful_prefer_access_token', FALSE) && isset($request['__application']['access_token']) { // The variable may be set if you want to be logged in both with a session // cookie and with an access token, favoriting the access_token request // see https://github.com/RESTful-Drupal/restful/issues/412. From b5baa90d4e112440984d21d8e7d279a9a762fc8d Mon Sep 17 00:00:00 2001 From: Brice Lenfant Date: Mon, 4 Dec 2017 12:58:24 +0200 Subject: [PATCH 7/7] close bracket. --- plugins/authentication/RestfulAuthenticationCookie.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/authentication/RestfulAuthenticationCookie.class.php b/plugins/authentication/RestfulAuthenticationCookie.class.php index 829ddea1..495fa53f 100644 --- a/plugins/authentication/RestfulAuthenticationCookie.class.php +++ b/plugins/authentication/RestfulAuthenticationCookie.class.php @@ -11,7 +11,7 @@ class RestfulAuthenticationCookie extends RestfulAuthenticationBase implements R */ public function applies(array $request = array(), $method = \RestfulInterface::GET) { // Skip cookies auth if we have an access token. - if (variable_get('restful_prefer_access_token', FALSE) && isset($request['__application']['access_token']) { + if (variable_get('restful_prefer_access_token', FALSE) && isset($request['__application']['access_token'])) { // The variable may be set if you want to be logged in both with a session // cookie and with an access token, favoriting the access_token request // see https://github.com/RESTful-Drupal/restful/issues/412.