Table of Contents

Single Sign-On (SSO) / Shared Authentication

About Single Sign-On

FoxyCart's SSO allows you to send an authenticated user from your own site to your FoxyCart checkout without needing to re-enter their username (email address) and password. In order to increase security and greatly reduce security risks, shared-authentication checkouts still require the customer to enter certain aspects of their payment information. As of v051, a shared-authentication customer can re-use a previously saved credit card, but the CSC must be entered.

This allows for a few interesting options in addition to just shared-authentication:

Requirements

How It Works

The Basic Idea

The basic idea of SSO is as follows:

  1. User creates an account or logs into SITE.
  2. On any user creation or modification, the SITE synchs the user's information with FoxyCart's customer records, using the API.
  3. When the user attempts to load the SITE's FoxyCart checkout (ie. from clicking “checkout” on the cart, from a direct to checkout request, etc.), the checkout redirects the user back to the SSO endpoint as configured in your FoxyCart store settings.
  4. The SITE's endpoint checks the current user's authentication status (on the SITE). This is possible because the endpoint is (probably) on the same domain as the SITE (where the initial authentication and any cookie-based sessions reside), and thus can access whatever session information might be available (such as the COOKIE headers).
  5. Based on the SITE's shared-authentication endpoint, the script can:
    • Redirect the user to the checkout, authenticated;
    • Redirect the user to the checkout, not authenticated; or
    • Take other action, such as redirect the user to a login or registration page, or deny checkout altogether.

The Details

What Is Passed To The Endpoint, and When It Happens

Read the above overview first. Then take note of some of the details below.

What Checkout Requires From The Endpoint

If shared-authentication is enabled, the checkout will not load unless a valid fc_auth_token (and other supporting information) is passed in (by your endpoint when it redirects the user). Here's what the checkout expects and requires.

The completed redirect might look something like this (in PHP):

$redirect_complete = 'https://yourdomain.foxycart.com/checkout?fc_auth_token=' . $auth_token . '&fcsid=' . $fcsid . '&fc_customer_id=' . $customer_id . '&timestamp=' . $timestamp;
header('Location: ' . $redirect_complete);

Note that if you append any additional fields after the required fields above you still must separate the values with an ampersand (&). For example, if you're pre-populating the checkout fields:

$redirect_complete = 'https://yourdomain.foxycart.com/checkout?fc_auth_token=' . $auth_token . '&fcsid=' . $fcsid . '&fc_customer_id=' . $customer_id . '&timestamp=' . $timestamp . '&customer_name=' . $customer_name;
header('Location: ' . $redirect_complete);

What Happens on Error

Troubleshooting

If you're convinced that FoxyCart is broken because you can't get SSO working, it's possible, but unlikely. Check a few common causes:

If you still can't get it working, please post in our forum and we'll be happy to help.

Sample Code