Skip to content

A simple sample Go web server with authentication (via OAuth, using Clef.io)

License

Unknown, Unknown licenses found

Licenses found

Unknown
LICENSE
Unknown
COPYING
Notifications You must be signed in to change notification settings

ChimeraCoder/go-server-bootstrap

Repository files navigation

Web Authentication in Go: Example

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.

Setup

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 define the following environment variables:

export COOKIE_SECRET = "something secret"
export APP_ID = "your clef app ID"
export APP_SECRET = "your clef app secret" 
export MONGODB_URL= "your mongodb url (without the mongodb:// prefix)"
export MONGODB_DATABASE = "the name of the mongodb database

You can also simply hard-code the definitions of the variables in a file named 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.

You can compile and run easily using the go run command. Alternatively, use go install to compile an executable and install it to $GOPATH/bin (you will probably want to add this to your $PATH for convenience)

This library has been tested using gc, though it should work with gccgo as well.

License

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).

About

A simple sample Go web server with authentication (via OAuth, using Clef.io)

Resources

License

Unknown, Unknown licenses found

Licenses found

Unknown
LICENSE
Unknown
COPYING

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published