Readymade sign up/in/out UX for golang.
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?
Calcutta
is an opinionated user auth flow built on top of likestripes/kolkata
go get -u github.com/likestripes/calcutta
import (
_ "github.com/likestripes/calcutta"
)
Kolkata
, and by extension Calcutta
, 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.
Calcutta
instantiates simple sign in / sign up forms at:
As well as a sign out endpoint here: /user/sign_out
Known issue -- as this is a GET request, a malicious third party could sign out the user via a cross site / iframe src-ing that URL
Once a user authenticates, they're passed back to either /user/hello
or /user/error
via your app.
Calcutta
establishes a basic sign in flow; to do something with that authenticated user, you'll probably want use Kolkata
. 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 SignIn
s (a token + password used for authentication) and attaches itself to the current session from your app via person, err := kolkata.Current(w, r)
.
The html found in /templates
gets compiled into templates.go
via github.com/mjibson/esc
-
forgot password flow
-
logging
-
documentation!
-
tests!
-
benchmarking
-
Contributors welcome!