How password should be encrypted? How session id should be generated and passed to the user? How session information should be saved? (cookie? file? database? memory?)
Also, I'd be interested in https, from theory to implementation.
How password should be encrypted? How session id should be generated and passed to the user? How session information should be saved? (cookie? file? database? memory?)
Also, I'd be interested in https, from theory to implementation.
How password should be encrypted?
Choose your package:
go get github.com/dchest/scrypt
go get code.google.com/p/go.crypto/bcrypt
go get code.google.com/p/go.crypto/pbkdf2
How session id should be generated and passed to the user?If you mean how you can authenticate logged in users, then you can use this package:
go get github.com/dchest/authcookie
How session information should be saved? (cookie? file? database? memory?)Up to you, but generally it's better to avoid cookies for storing anything other than IDs. There are a few packages for "sessions" like in PHP, but I don't remember their names.
One more important question to add:
How do I protect against XSRF attacks?
go get code.google.com/p/xsrftoken
You can read documentation for these packages here:
http://go.pkgdoc.org/As for HTTPS, it's a complicated thing. Pick any good book on it, then apply your knowledge to the standard package crypto/tls (http://golang.org/pkg/crypto/tls/).
Due to Go's pervasive use of io.Writer / io.Reader / net.Conn interfaces, once you have the problem of loading keys sorted, everything else is the same as writing a plain old TCP/IP listener. Configuring TLS will always be a pain -- decades, committees and broken implementations have seen to that.
As for actually verifying passwords and session integrity, Go's crypto packages are also pretty straightforwards and composable. The crypto/hmac [4] package is easily combined with various implementations of hash.Hash. In exchange for this simplicity, though, Go gives you plenty of opportunity to emulate LinkedIn and blow your own foot off, forgetting salt and common sense. There are plenty of higher level packages that offer to do it for you. (Blow your foot off, or hash your passwords -- I recommend reading implementations to decide which. :))
Also of interest when dealing with writing webapps in Go, the database/sql [5] package is an important abstraction. Since it is a more recent package, it often doesn't show up in google searches for sqlite, postgres, etc. This can give an impression that Go's database support is fragmented.
1 -- http://golang.org/pkg/net/http/#ListenAndServeTLS
2 -- http://golang.org/pkg/net/http/#Transport
3 -- http://golang.org/pkg/crypto/tls/#Listener