Support from Acquia helps fund testing for Drupal Acquia logo

Comments

juampynr’s picture

Status: Active » Needs review
FileSize
1.68 KB

First pass. I am getting the following error when REST module is enabled and then I enable OAuth:

ReflectionException: Class Drupal\oauth\Authentication\Provider\OAuthProvider does not exist in ReflectionClass->__construct() (line 961 of /home/juampy/projects/drupal8b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/ContainerBuilder.php).
The website has encountered an error. Please try again later.
ygerasimov’s picture

Status: Needs review » Needs work
+++ b/oauth.services.ymlundefined
@@ -0,0 +1,6 @@
+services:
+  oauth.provider:
+    class: Drupal\oauth\Authentication\Provider\OAuthProvider
+    arguments: ['@config.factory']

Please have a key authentication.oauth when registering service in container.

From latest patch of #1890878.

+  public function addProvider($provider_id, AuthenticationProviderInterface $provider, $priority = 0) {
+    $provider_id = substr($provider_id, strlen('authentication.'));
+
+    $this->providers[$provider_id] = $provider;
+    $this->providerOrders[$priority][$provider_id] = $provider;
+    // Force the builders to be re-sorted.
+    $this->sortedProviders = NULL;
+  }
juampynr’s picture

Great! The provider is picked up now. I am looking at how the authenticate() method should work.

juampynr’s picture

Figured out. Now moving on to how to use the authenticate() method to authenticate the request.

juampynr’s picture

Title: Make Oauth an AuthenticationProvider » Make Oauth module an AuthenticationProvider

Improving title.

corvus_ch’s picture

Nice work so far. Just a few notes from my side.

+++ b/oauth.services.ymlundefined
@@ -0,0 +1,6 @@
+    arguments: ['@config.factory']

This will path in the config service to the constructor. You currently do not need it so this line can be deleted.

If you have the feeling that you might need the config service. Implement a constructor and store the config to a class variable. See Drupal\Core\Authentication\Provider\ HttpBasic

+++ b/oauth.services.ymlundefined
@@ -0,0 +1,6 @@
+      - { name: authentication_provider, priority: 1000 }

You might want to reduce that. Basic Auth has a priority of 100. Applying the same priority will be sufficient.

juampynr’s picture

Done :D

Continuing with the authenticate() method.

pcambra’s picture

Status: Needs work » Needs review
juampynr’s picture

Status: Needs review » Postponed

There are several errors in CMI when importing rest.settings.yml. I want to set this up first in core before starting to work in authenticating requests (there is no way to set this up if rest.settings.yml cannot be imported).

juampynr’s picture

Status: Postponed » Active

REST module configured locally (fixed a confusing bug in core while setting it up).

I have committed the above patch at 8.x-1.x.

I have been reading the docs of the OAuth PECL library

Now I am implementing two-legged-authentication at the authenticate() method of OAuthProvider class based in this example:

http://svn.php.net/viewvc/pecl/oauth/trunk/examples/provider/2legged.php...

More soon.

juampynr’s picture

Added basic implementation that supports the PECL library.

http://drupalcode.org/project/oauth.git/commitdiff/81db8ad

TODO:
* Improve README.txt
* Test the _auth option at a route to verify that a resource can only be accessed when the request is signed with OAuth.
* Implement the three-legged authentication.
* Implement the UI so users can obtain/manage OAuth Authorizations.

juampynr’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.