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
Comment #2
uros.ceh commentedThe provided patch replaces native PHP realpath() calls with Drupal file_system service calls.
Comment #3
uros.ceh commentedComment #4
hn0852 commentedHad 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
Comment #5
e0ipsoThis looks great! Thanks for the patch.
Comment #6
uros.ceh commentedThe latest patch does not seem to apply anymore so I'm providing an update for the latest module version.
Comment #7
bradjones1Comment #8
bojan_dev commentedThis is available in version 6.