app

package
v0.0.0-...-9bc9026 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2018 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertPlainPassword

func ConvertPlainPassword(rawUsername, rawPassword string) string

ConvertPlainPassword hashes a raw password and returns the hashed password

func CreateHash

func CreateHash(key string) string

CreateHash creates a new hash string

Types

type CookieManager

type CookieManager interface {
	Init()
	FetchCookie(r *http.Request) database.CookieData
	CreateCookie(w http.ResponseWriter, m bson.ObjectId, urlString string) string
	DeleteClientCookie(w http.ResponseWriter, urlString string) string
	DeleteDBCookie(clientCookie database.CookieData, session *mgo.Session) error
	DecodeDBCookieData(data database.CookieData, session *mgo.Session) database.CookieData
	AuthenticateCookie(w http.ResponseWriter, Server *Server, clientCookie database.CookieData, session *mgo.Session) error
}

CookieManager is for managing one secure cookie

type SCManager

type SCManager struct {
	// contains filtered or unexported fields
}

SCManager implements CookieManager interface. Also holds a SecureCookie

func (*SCManager) AuthenticateCookie

func (SCManager *SCManager) AuthenticateCookie(w http.ResponseWriter, Server *Server, clientCookie database.CookieData, session *mgo.Session) error

AuthenticateCookie checks client cookie towards db cookie to validate the client cookie Returns an error if authentication failed

func (*SCManager) CreateCookie

func (SCManager *SCManager) CreateCookie(w http.ResponseWriter, m bson.ObjectId, urlString string) string

CreateCookie creates a client cookie with login credentials and encodes it encoded data will be returned as string as well as set in http

func (*SCManager) DecodeDBCookieData

func (SCManager *SCManager) DecodeDBCookieData(data database.CookieData, session *mgo.Session) database.CookieData

DecodeDBCookieData decodes cookie data Returns decoded cookie data if success

func (*SCManager) DeleteClientCookie

func (SCManager *SCManager) DeleteClientCookie(w http.ResponseWriter, urlString string) error

DeleteClientCookie deletes(overwrites) client cookie. Returns error if it failed

func (*SCManager) DeleteDBCookie

func (SCManager *SCManager) DeleteDBCookie(clientCookie database.CookieData, Server *Server, session *mgo.Session) error

DeleteDBCookie deletes all cookies with same user id as sent cookie Returns error if failed

func (*SCManager) FetchCookie

func (SCManager *SCManager) FetchCookie(r *http.Request) (database.CookieData, error)

FetchCookie retrieves the client cookie and decodes its content. Returns the decoded data and an error

func (*SCManager) Init

func (SCManager *SCManager) Init()

Init initializes the secure cookie instance by generating random keys of 32 byte length

type Server

type Server struct {
	Port        string
	Database    database.Db
	StaticPages map[int][]byte
}

Server struct containing server information

Jump to

Keyboard shortcuts

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