bakery

package
v0.0.0-...-386a0b5 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUnknownBakeryID = errors.New(`bakery: could not determine bakery user id`)
View Source
var ErrUnknownCookieType = errors.New("bakery: unknown cookie type")
View Source
var ErrUnknownUserEmail = errors.New(`bakery: could not determine user email`)
View Source
var ErrUnknownUserRole = errors.New("bakery: could not determine user role")
View Source
var ErrUnknownUsername = errors.New(`bakery: could not determine username`)

Functions

func CreateChocolatechipCookie

func CreateChocolatechipCookie(username, email string, role string, buid int64) (string, error)

CreateChocolatechipCookie generates an HMAC-signed cookie encrypted with AES-128 (ECB mode). Such cookie is to be used with Drupal Bakery SSO module for transferring user credentials. (in gophish app we do not issue CHOCOLATECHIPSSL cookies so this func is used for testing only)

func CreateOatmealCookie

func CreateOatmealCookie(username, password, destination, slave string) (string, error)

CreateOatmealCookie generates an HMAC-signed cookie encrypted with AES-128 (ECB mode). Such cookie is to be used with Drupal Bakery SSO module for transferring login credentials.

func Decrypt

func Decrypt(cookie string) (string, error)

Decrypt decrypts the given encrypted cookie

func Encrypt

func Encrypt(data string) (string, error)

Encrypt encrypts the given string

func Key

func Key() string

Key returns the encryption key or panics if its not set

func SetKey

func SetKey(encryptionKey string)

SetKey sets encryption key

Types

type Cookie struct {
	Raw             string
	IsOatmeal       bool
	IsChocolateChip bool
	User            string
	Email           string
	Role            string
	BakeryID        int64
	Error           string
}

Cookie contains props of a Bakery SSO cookie

func ParseCookie

func ParseCookie(cookie string) (*Cookie, error)

ParseCookie decrypts an HMAC-signed cookie encrypted with AES-128 (ECB mode), parses the underlying serialized PHP data structure and returns some props wrapped in Cookie type.

Jump to

Keyboard shortcuts

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