session

package
v0.0.0-...-f84ac71 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2017 License: MIT Imports: 10 Imported by: 1

README

gorails/session

Build Status

Installation

With Go and git installed:

go get -u github.com/adjust/gorails/session

Usage

import "github.com/adjust/gorails/session"

// sessionCookie - raw _<your app name>_session cookie
func getRailsSessionData(sessionCookie string) (decryptedCookieData []byte, err error) {
  decryptedCookieData, err = session.DecryptSignedCookie(sessionCookie, secretKeyBase, salt, signSalt)

  return
}

const (
  secretKeyBase = "..."                      // can be found in config/initializers/secret_token.rb
  salt          = "encrypted cookie"         // default value for Rails 4 app
  signSalt      = "signed encrypted cookie"  // default value for Rails 4 app
)

After you decrypted session data you might like to deserialize it using gorails/marshal if your Rails version is less than v4.1 and you use the default serializer config.

Rails use JSON as its default serializer from v4.1, so you can deserialize the decrypted session data as a common JSON data as what test does.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidSignature = errors.New("session: signature not verified")

Functions

func DecryptSignedCookie

func DecryptSignedCookie(signedCookie, secretKeyBase, salt, signSalt string) (session []byte, err error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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