Go is a new and emerging language that is both fun and easy to learn.
This application is a simple demonstration of how to get a basic application with authentication (via OAuth) up and running using Go.
The OAuth provider used is Clef.io, a new approach to passwords and mobile-enabled authentication.
Assuming you already have a working installation of a Go compiler (either gc or gccgo), you simply need to define the OAuth credentials and cookie secret.
If you want to define these as environment variables (ie, export APP_ID=YOURAPPID), simply create a file named conf.go
with the following contents:
package main
import "os"
var COOKIE_SECRET = []byte(os.Getenv("COOKIE_SECRET"))
var APP_ID = os.Getenv("APP_ID")
var APP_SECRET = os.Getenv("APP_SECRET")
You can also simply hard-code the strings in the conf.go file instead; this file has not been included in the repository because it is already in the .gitignore file, to avoid committing your credentials by mistake.
A Makefile has been included so you can compile and run easily:
$ make && ./build/a.out
This library has been tested using gc, though it should work with gccgo as well.
Copyright (C) 2012 Aditya Mukerjee
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of the author(s) shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from those author(s).