kolkata

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

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

Go to latest
Published: Aug 17, 2015 License: MIT Imports: 9 Imported by: 3

README

Kolkata

A golang library for more personable apps.

Warning

This is v.01 -- it has no tests, performance is probably awful and it's not proven safe in production anywhere. But maybe it'll scratch an itch?

WTF

Kolkata is an opinionated user/session auth API that is designed to make a variety of user sign up scenarios easy.

Quick Start? Use Calcutta!

Calcutta implements a basic sign in form for Kolkata, so if you want to get started immediately, check out likestripes/calcutta

Otherwise, read on to set it up...

Install / Import

go get -u github.com/likestripes/kolkata

import (
	"github.com/likestripes/kolkata"
)

Dependency on Pacific

Kolkata uses likestripes/pacific as an opinionated ORM. Pacific currently supports AppEngine and Postgres.

Google AppEngine: goapp serve works out of the box (they include the buildtag for you)

Postgres: go run -tags 'postgres' main.go -- details in the pacific/Readme.

Overview

Kolkata is designed to export a Person struct that can be mixed into whatever WildAndCrazyUser model your app requires:

type Person struct {
	PersonId    int64
	PersonIdStr string
	Timestamp   time.Time
	Secret      string
	Anon        bool   `datastore:"-" sql:"-" json:"-"`
	Scope       *Scope `datastore:"-" sql:"-" json:"-"`
}

The Person has n SignIns (a token + password used for authentication) and attaches itself to the current session from your app via person, err := kolkata.Current(w, r)

TODO
  • logging

  • documentation!

  • tests!

  • benchmarking

  • Contributors welcome!

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Person

type Person struct {
	PersonId    int64
	PersonIdStr string
	Timestamp   time.Time
	Secret      string
	Anon        bool   `datastore:"-" sql:"-" json:"-"`
	Scope       *Scope `datastore:"-" sql:"-" json:"-"`
}

func Current

func Current(w http.ResponseWriter, r *http.Request) (person Person, err error)

func (*Person) Save

func (person *Person) Save(sign_ins ...map[string]string) int64

type Scope

type Scope struct {
	Writer    http.ResponseWriter
	Request   *http.Request
	Context   pacific.Context
	Bootstrap string
	Host      string
	Person    Person
	NewUser   bool
	Min       bool
}

func CreateScope

func CreateScope(w http.ResponseWriter, r *http.Request) (scope Scope)

func (*Scope) ClearSession

func (scope *Scope) ClearSession(w http.ResponseWriter, r *http.Request)

func (*Scope) NewSession

func (scope *Scope) NewSession(person_id ...int64)

func (*Scope) Session

func (scope *Scope) Session() (person Person, err error)

func (*Scope) SessionCookie

func (scope *Scope) SessionCookie(person_id_str string, session_cookie http.Cookie, personid_cookie http.Cookie)

type Session

type Session struct {
	PersonId  string // TODO: this is not intuitive
	RandomInt int64  `json:",string"`
	SessionId []byte
}

type SignIn

type SignIn struct {
	Token        string `gorm:"column:signin_id"`
	PersonId     int64
	PasswordHash []byte
	Unsafe       string          `datastore:"-" sql:"-" json:"-"`
	Context      pacific.Context `datastore:"-" sql:"-" json:"-"`
}

func (SignIn) Auth

func (signin SignIn) Auth() (int64, error)

func (*SignIn) Get

func (signin *SignIn) Get() error

func (SignIn) Save

func (signin SignIn) Save() (SignIn, error)

Jump to

Keyboard shortcuts

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