sesame

package module
v0.0.0-...-fd4eab2 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2013 License: Apache-2.0 Imports: 10 Imported by: 0

README

Sesame

Build Status

A Go library for implementing user storage over the network.

Left to do:

  • storage backends
  • a server/client (probably using go-discover and some sort of JSON RPC)

And if you know anything about cryptography, please do have a look. I would really appreciate more eyes on this code.

Bitdeli Badge

Releases

  • 0.1.0: Basic email/password and persistence with RethinkDB

Track "develop" for bleeding edge releases, which will probably break things.

Documentation

Overview

Package sesame is a email/password storage system using RethinkDB and scrypt.

TODO: better docs

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Password

type Password []byte

Password stores an encrypted password

func NewPassword

func NewPassword(salt Salt, plaintext []byte) (password Password, err error)

NewPassword creates a new password, using the constants defined in this package.

type Salt

type Salt []byte

A Salt represents a cryptographically random salt value

func NewSalt

func NewSalt(length int) (salt Salt, err error)

NewSalt generates cryptographically random salts

type User

type User struct {
	Id       interface{} `gorethink:"id"`
	Email    string      `gorethink:"email"`
	Password Password    `gorethink:"password"`
	Salt     Salt        `gorethink:"salt"`

	Created time.Time `gorethink:"created"`
	Updated time.Time `gorethink:"updated"`
}

A User combines Password and Salt into an interface to validate plaintext against.

func NewUser

func NewUser(email, password string) *User

NewPassword creates a new User struct and hashes the password. Created and Updated fields will be set to the time of creation.

func (*User) ChangePassword

func (u *User) ChangePassword(original, updated []byte) error

ChangePassword is a convenience method to set a new password on a User if and only if the original is valid.

func (*User) SetPassword

func (u *User) SetPassword(plaintext []byte) error

SetPassword sets a new hashed password from plaintext

func (*User) ValidatePassword

func (u *User) ValidatePassword(plaintext []byte) (bool, error)

ValidatePassword validates a plaintext password against the stored hash

type UserStore

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

UserStore manages connections for persisting Users to RethinkDB

func NewUserStore

func NewUserStore() (*UserStore, error)

NewUserStore creates a new `UserStore` from the environment

func (*UserStore) Delete

func (store *UserStore) Delete(email string) error

Delete deletes a user by email.

func (*UserStore) Get

func (store *UserStore) Get(email string) (*User, error)

Get takes an email address and returns a *User, or an error

func (*UserStore) Save

func (store *UserStore) Save(user *User) error

Save takes a *User and saves it to RethinkDB. It updates User.Updated, as well.

type UserStoreConfig

type UserStoreConfig struct {
	URL      string
	PoolSize int
}

UserStoreConfig stores configuration from envconfig.

  • `URL`: something like rethinkdb://authkey@host:port/dbname
  • `PoolSize`: the maximum number of connections to hold, idles at half of this value.

Jump to

Keyboard shortcuts

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