GithubHelp home page GithubHelp logo

Comments (2)

qpi avatar qpi commented on July 30, 2024

Finally I've found a workaround (not too beautiful):
my main.php:

'oauth2' => [
    'class' => 'filsh\yii2\oauth2server\Module',
    'tokenParamName' => 'accessToken',
    'tokenAccessLifetime' => 3600 * 24,
    'storageMap' => [
        'user_credentials' => 'common\models\User',
        'refresh_token' => 'path\to\oauth2\MongoDB',
        'access_token' => 'path\to\oauth2\MongoDB',
        'client' => 'path\to\oauth2\MongoDB',
        'authorization_code' => 'path\to\oauth2\FakeStorage',
        'client_credentials' => 'path\to\oauth2\FakeStorage',
        'public_key' => 'path\to\oauth2\FakeStorage',
        'jwt_bearer' => 'path\to\oauth2\FakeStorage',
        'scope' => 'path\to\oauth2\FakeStorage',
    ]
]

and a fake storage class:

class FakeStorage implements
    \OAuth2\Storage\AuthorizationCodeInterface,
    \OAuth2\Storage\ClientCredentialsInterface,
    \OAuth2\Storage\PublicKeyInterface,
    \OAuth2\Storage\JWTBearerInterface,
    \OAuth2\Storage\ScopeInterface,
    \OAuth2\Storage\RefreshTokenInterface,
    \OAuth2\Storage\AccessTokenInterface
{
    //for AuthorizationCodeInterface
    public function getAuthorizationCode($code){}
    public function setAuthorizationCode($code, $client_id, $user_id, $redirect_uri, $expires, $scope = null){}
    public function expireAuthorizationCode($code){}
    //for ClientCredentialsInterface
    public function checkClientCredentials($client_id, $client_secret = null){}
    public function isPublicClient($client_id){}
    public function getClientDetails($client_id){}
    public function getClientScope($client_id){}
    public function checkRestrictedGrantType($client_id, $grant_type){}
    //for PublicKeyInterface
    public function getPublicKey($client_id = null){}
    public function getPrivateKey($client_id = null){}
    public function getEncryptionAlgorithm($client_id = null){}
    //for JWTBearerInterface
    public function getClientKey($client_id, $subject){}
    public function getJti($client_id, $subject, $audience, $expiration, $jti){}
    public function setJti($client_id, $subject, $audience, $expiration, $jti){}
    //for ScopeInterface
    public function scopeExists($scope){}
    public function getDefaultScope($client_id = null){}
    //for RefreshTokenInterface
    public function getRefreshToken($refresh_token){}
    public function setRefreshToken($refresh_token, $client_id, $user_id, $expires, $scope = null){}
    public function unsetRefreshToken($refresh_token){}
    //for AccessTokenInterface
    public function getAccessToken($oauth_token){}
    public function setAccessToken($oauth_token, $client_id, $user_id, $expires, $scope = null){}
}

The FakeStorage class implements all the possibble interfaces, that's why You can set it for all the storages which are usess for Your application.

from yii2-oauth2-server.

mtangoo avatar mtangoo commented on July 30, 2024

#43

from yii2-oauth2-server.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.