Documentation
¶
Index ¶
- Variables
- func Compare(hash, unhashed []byte) bool
- func Decode(input []byte) []byte
- func Decrypt(ciphertext []byte, key []byte) (plaintext []byte)
- func Encode(input []byte) []byte
- func Encrypt(plaintext []byte, key []byte) (ciphertext []byte)
- func Hash(plaintext []byte) []byte
- func NewEncryptionKey() []byte
- func UserExists(username string, users *mgo.Collection) bool
- type Matrix
- type User
Constants ¶
This section is empty.
Variables ¶
var CookieCoder = base64.URLEncoding.WithPadding('*')
CookieCoder is a base64 encoding that a web browser can store as a cookie
Functions ¶
func Compare ¶
Compare compares a hash and a password and returns bool
func Decode ¶
Decode Decodes an input byte array and returns the result
func Decrypt ¶
Decrypt decrypts an input using the key and returns the plaintext result
func Encode ¶
Encode CookieEncodes an input byte array and returns the result
func Encrypt ¶
Encrypt encrypts an input using the key and returns the encrypted result
func NewEncryptionKey ¶
func NewEncryptionKey() []byte
NewEncryptionKey generates a random encryption key
func UserExists ¶
func UserExists(username string, users *mgo.Collection) bool
UserExists checks if user with specified username exists in specified collection
Types ¶
type Matrix ¶
Matrix stores frequently used authkeys
type User ¶
type User struct {
ID bson.ObjectId `bson:"_id,omitempty"`
Username string
Password []byte
AuthKeys [][]byte
}
User database object for user
func CreateUser ¶
func CreateUser(username, password string, users *mgo.Collection) (*User, error)
CreateUser makes a new user and inserts into specified collection
func FetchUser ¶
func FetchUser(username string, users *mgo.Collection) *User
FetchUser returns a user object from the username
func FindUserByAuthKey ¶
func FindUserByAuthKey(key string, users *mgo.Collection, matrix Matrix) *User
FindUserByAuthKey returns a user object from the authkey
func (*User) Authenticate ¶
Authenticate checks authentication key to see if its valid
func (*User) Login ¶
func (u *User) Login(password string, users *mgo.Collection) string
Login logins a user and returns an authentication string
func (*User) UpdateKeys ¶
func (u *User) UpdateKeys(newKey []byte, users *mgo.Collection)
UpdateKeys expires and "old" key and replaces it with a new one
Source Files
¶
- Encode.go
- Encrypt.go
- Hash.go
- Matrix.go
- User.go