ASK, how to get the public key to show to specific url
Opened this issue · 1 comments
ahmadfadlydziljalal commented
In doc:
<?php
namespace app\storage;
class PublicKeyStorage implements \OAuth2\Storage\PublicKeyInterface{
private $pbk = null;
private $pvk = null;
public function __construct()
{
$this->pvk = file_get_contents('privkey.pem', true);
$this->pbk = file_get_contents('pubkey.pem', true);
}
public function getPublicKey($client_id = null){
return $this->pbk;
}
public function getPrivateKey($client_id = null){
return $this->pvk;
}
public function getEncryptionAlgorithm($client_id = null){
return 'RS256';
}
}
Then , I wrote this action in a controller:
class OpenIdController extends BaseRestController
{
/**
* @throws InvalidConfigException
*/
public function actionPublicKey()
{
/** @var Module $module */
$module = Yii::$app->getModule('oauth2');
die(Html::tag('pre', VarDumper::dumpAsString($module->getServer()->getStorage('public_key')->someWhat ? )));
}
Thanks
ahmadfadlydziljalal commented
#SOLVED
/**
* @throws InvalidConfigException
*/
public function actionPublicKey()
{
/** @var Module $module */
$module = Yii::$app->getModule('oauth2');
return $module->getServer()
->getStorage('public_key')
->getPublicKey('some-client-id');
}
```