multipass

package module
v0.0.0-...-44b455f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 11, 2019 License: MIT Imports: 13 Imported by: 0

README

goify-multipass

Implementation of shopify's multipass in golang

Shopify provides a mechanism for single sign-on known as Multipass. Multipass uses an AES encrypted JSON hash and multipassify provides functions for generating tokens

More details on Multipass with Shopify can be found here.

Installation

    go get github.com/claimh-solais/goify-multipass

Usage

To use Multipass an Enterprise / Plus plan is required. The Multipass secret can be found in your shop Admin (Settings > Checkout > Customer Accounts). Make sure "Accounts are required" or "Accounts are optional" is selected and Multipass is enabled.

    import multipass "github.com/claimh-solais/goify-multipass"

    // Construct the Multipassify encoder
    m := multipass.New("SHOPIFY MULTIPASS SECRET")

    // Create your customer info hash
    customerInfo := map[string]interface{}{
        "email": "test@example.com",
        "remote_ip": "USERS IP ADDRESS",
        "return_to": "http://some.url",
        ...ADDITIONAL_METADATA_FIELDS,
    })

    // Encode a Multipass token
    token := m.Encode(customerInfo)

    // Generate a Shopify multipass URL to your shop
    urlString := m.GenerateURL(customerInfo, "yourstorename.myshopify.com")

  // Generates a URL like:  https://yourstorename.myshopify.com/account/login/multipass/<MULTIPASS-TOKEN>

Documentation

Index

Constants

View Source
const TimeISO8601Layout = "2013-04-11T15:16:23-04:00"

TimeISO8601Layout timestamp in ISO8601 encoding

Variables

This section is empty.

Functions

This section is empty.

Types

type Multipass

type Multipass struct {
	EncryptionKey []byte
	SignatureKey  []byte
}

Multipass comment

func New

func New(secret string) (ctx *Multipass, err error)

New comment

func (*Multipass) Encode

func (ctx *Multipass) Encode(customerInfo map[string]interface{}) (token string, err error)

Encode comment

func (*Multipass) GenerateURL

func (ctx *Multipass) GenerateURL(customerInfo map[string]interface{}, domain string) (u *url.URL, err error)

GenerateURL comment

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL