Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ASK, how to get the public key to show to specific url #157

Open
ahmadfadlydziljalal opened this issue Feb 7, 2024 · 1 comment
Open

Comments

@ahmadfadlydziljalal
Copy link

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
Copy link
Author

#SOLVED

 /**
     * @throws InvalidConfigException
     */
    public function actionPublicKey()
    {
        /** @var Module $module */
        $module = Yii::$app->getModule('oauth2');
        return $module->getServer()
            ->getStorage('public_key')
            ->getPublicKey('some-client-id');
    }
    ```

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant