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

Multiple Grant Type Support in Heimdall #19

Open
doelmi opened this issue Jul 22, 2022 · 0 comments
Open

Multiple Grant Type Support in Heimdall #19

doelmi opened this issue Jul 22, 2022 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@doelmi
Copy link

doelmi commented Jul 22, 2022

Is your feature request related to a problem? Please describe.

I want to have multiple grant type in one server, is there any good example to do it?

Describe the solution you'd like

I have done it, but with condition from what grant_type value is.

// function to create a new instance of HeimdallAuthorizationServer
    static function createAuthorizationServer($grant_type = null)
    {
        // creating HeimdallAuthorizationServer config
        $config = Heimdall::withAuthorizationConfig(
            new ClientRepository(),
            new AccessTokenRepository(),
            new ScopeRepository(),
            __DIR__ . '/private.key'
        );

        $grant = null;
        switch ($grant_type) {
            case 'client_credentials':
                $grant = Heimdall::withClientCredentialsGrant('P1Y');
                break;
            default:
                // creating HeimdallAuthorizationServer grant
                $grant = Heimdall::withAuthorizationCodeGrant(
                    new AuthCodeRepository(),
                    new RefreshTokenRepository(),
                    'PT1H',
                    'P6M',
                    'P3M'
                );
                break;
        }

        // return a new instance of HeimdallAuthorizationServer
        return Heimdall::initializeAuthorizationServer($config, $grant);
    }

Describe alternatives you've considered

Instead of using condition above, is there any other solution, that can make multiple grant_type support?

Additional context

In League Library source code, it is possible to do it. What's about implementation in Heimdall?

@ezralazuardy ezralazuardy self-assigned this May 25, 2024
@ezralazuardy ezralazuardy added the enhancement New feature or request label May 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants