node-bigcommerce icon indicating copy to clipboard operation
node-bigcommerce copied to clipboard

SSO integration

Open nidhinprathap opened this issue 5 years ago • 4 comments

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');
    }

nidhinprathap avatar Jul 01 '20 04:07 nidhinprathap

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

stefanosala avatar Jul 01 '20 07:07 stefanosala

Ok, thanks for the update

nidhinprathap avatar Jul 02 '20 11:07 nidhinprathap

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

nidhinprathap avatar Jul 02 '20 11:07 nidhinprathap

That would be amazing! 🔝

stefanosala avatar Jul 02 '20 11:07 stefanosala