There seems to be an issue when setting up public and private keys with stream URIs on admin/config/people/simple_oauth configuration form. The problem is in the usage of PHP native realpath function, which does not support stream wrappers. These calls should be replaced with the Drupal file_system realpath() method, which checks if URI is a stream and converts it to an absolute path.

Currently there are 2 places where PHP realpath() function is used to generate absolute pathnames.

In Oauth2GrantManager


$server = new AuthorizationServer(
      $this->clientRepository,
      $this->accessTokenRepository,
      $this->scopeRepository,
      realpath($this->privateKeyPath),
      Core::ourSubstr($salt, 0, 32),
      $this->responseType
    );

and in ResourceServer


try {
      $public_key = $config_factory->get('simple_oauth.settings')->get('public_key');
      $public_key_real = realpath($public_key);
      if ($public_key && $public_key_real) {
        $this->subject = new LeageResourceServer(
          $access_token_repository,
          $public_key_real
        );
      }
    }

Comments

uros.ceh created an issue. See original summary.

uros.ceh’s picture

The provided patch replaces native PHP realpath() calls with Drupal file_system service calls.

uros.ceh’s picture

Status: Active » Needs review
hn0852’s picture

Had the same issue, went here and just saw this. For me the problem was at line 149 of file simple_oauth/src/Plugin/Oauth2GrantManager.php because of the use of realpath with a "private://" uri

e0ipso’s picture

This looks great! Thanks for the patch.

uros.ceh’s picture

The latest patch does not seem to apply anymore so I'm providing an update for the latest module version.

bradjones1’s picture

Version: 8.x-4.x-dev » 5.x-dev
bojan_dev’s picture

Version: 5.x-dev » 6.x-dev
Status: Needs review » Closed (outdated)

This is available in version 6.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.