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

SSO integration #86

Open
nidhinprathap opened this issue Jul 1, 2020 · 4 comments
Open

SSO integration #86

nidhinprathap opened this issue Jul 1, 2020 · 4 comments

Comments

@nidhinprathap
Copy link

Hi, BigCommerce provides different types of authentication nowadays. While going through the library I couldn't see an SSO integration basically which generates a single sign-in URL. Source

While going through the official library I saw there are methods to achieve it. It's a small piece of code easy to plugin. But at the same time I didn't see any implementation of SSO in this library. Have I missed it or the implementation is missing?

Sample code from Official Library

/**
     * @param int $id
     * @param string $redirectUrl
     * @param string $requestIp
     * @return string
     */
    public static function getCustomerLoginToken($id, $redirectUrl = '', $requestIp = '')
    {
        if (empty(self::$client_secret)) {
            throw new Exception('Cannot sign customer login tokens without a client secret');
        }

        $payload = array(
            'iss' => self::$client_id,
            'iat' => time(),
            'jti' => bin2hex(random_bytes(32)),
            'operation' => 'customer_login',
            'store_hash' => self::$store_hash,
            'customer_id' => $id
        );

        if (!empty($redirectUrl)) {
            $payload['redirect_to'] = $redirectUrl;
        }

        if (!empty($requestIp)) {
            $payload['request_ip'] = $requestIp;
        }

        return JWT::encode($payload, self::$client_secret, 'HS256');
    }
@stefanosala
Copy link
Contributor

Hi there, we don't have anything like this, yet, unfortunately.

@nidhinprathap
Copy link
Author

Ok, thanks for the update

@nidhinprathap
Copy link
Author

May can be added as a feature, can build and raise a PR

@stefanosala
Copy link
Contributor

That would be amazing! 🔝

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

2 participants