goth

package module
v0.0.0-...-70932a3 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2015 License: MIT Imports: 2 Imported by: 0

README

Goth: Multi-Provider Authentication for Go Build Status

Package goth provides a simple, clean, and idiomatic way to write authentication packages for Go web applications.

Unlike other similar packages, Goth, let's you write OAuth, OAuth2, or any other protocol providers, as long as they implement the Provider and Session interfaces.

This package was inspired by https://github.com/intridea/omniauth.

Docs

The API docs can be found at http://godoc.org/github.com/markbates/goth

Installation

$ go get github.com/markbates/goth

Supported Providers

  • Bitbucket
  • Digital Ocean
  • Dropbox
  • Facebook
  • GitHub
  • Google+
  • Lastfm
  • Linkedin
  • Spotify
  • Twitch
  • Twitter

Examples

See the examples folder for a working application that lets users authenticate through Twitter, Facebook or Google Plus.

Issues

Issues always stand a significantly better chance of getting fixed if the are accompanied by a pull request.

Contributing

Would I love to see more providers? Certainly! Would you love to contribute one? Hopefully, yes!

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Write Tests!
  4. Commit your changes (git commit -am 'Add some feature')
  5. Push to the branch (git push origin my-new-feature)
  6. Create new Pull Request

Contributers

  • Mark Bates
  • Tyler Bunnell
  • Craig P Jolicoeur
  • Zac Bergquist
  • Ben Tranter
  • Noah Shibley
  • oov
  • Tyler
  • Rafael Quintela
  • Noah
  • DenSm
  • HaiMing.Yin
  • Masanobu YOSHIOKA
  • bryanl
  • dkhamsing
  • Jerome Touffe-Blin
  • Jonathan Hall

Documentation

Overview

Package goth provides a simple, clean, and idiomatic way to write authentication packages for Go web applications.

This package was inspired by https://github.com/intridea/omniauth.

See the examples folder for a working application that lets users authenticate through Twitter or Facebook.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClearProviders

func ClearProviders()

ClearProviders will remove all providers currently in use. This is useful, mostly, for testing purposes.

func UseProviders

func UseProviders(viders ...Provider)

UseProviders sets a list of available providers for use with Goth.

Types

type Params

type Params interface {
	Get(string) string
}

Params is used to pass data to sessions for authorization. An existing implementation, and the one most likely to be used, is `url.Values`.

type Provider

type Provider interface {
	Name() string
	BeginAuth(state string) (Session, error)
	UnmarshalSession(string) (Session, error)
	FetchUser(Session) (User, error)
	Debug(bool)
}

Provider needs to be implemented for each 3rd party authentication provider e.g. Facebook, Twitter, etc...

func GetProvider

func GetProvider(name string) (Provider, error)

GetProvider returns a previously created provider. If Goth has not been told to use the named provider it will return an error.

type Providers

type Providers map[string]Provider

Providers is list of known/available providers.

func GetProviders

func GetProviders() Providers

GetProviders returns a list of all the providers currently in use.

type Session

type Session interface {
	// GetAuthURL returns the URL for the authentication end-point for the provider.
	GetAuthURL() (string, error)
	// Marshal generates a string representation of the Session for storing between requests.
	Marshal() string
	// Authorize should validate the data from the provider and return an access token
	// that can be stored for later access to the provider.
	Authorize(Provider, Params) (string, error)
}

Session needs to be implemented as part of the provider package. It will be marshaled and persisted between requests to "tie" the start and the end of the authorization process with a 3rd party provider.

type User

type User struct {
	RawData           map[string]interface{}
	Provider          string
	Email             string
	Name              string
	NickName          string
	Description       string
	UserID            string
	AvatarURL         string
	Location          string
	AccessToken       string
	AccessTokenSecret string
}

User contains the information common amongst most OAuth and OAuth2 providers. All of the "raw" datafrom the provider can be found in the `RawData` field.

Directories

Path Synopsis
Package gothic wraps common behaviour when using Goth.
Package gothic wraps common behaviour when using Goth.
providers
bitbucket
Package bitbucket implements the OAuth2 protocol for authenticating users through Bitbucket.
Package bitbucket implements the OAuth2 protocol for authenticating users through Bitbucket.
dropbox
Package dropbox implements the OAuth2 protocol for authenticating users through Dropbox.
Package dropbox implements the OAuth2 protocol for authenticating users through Dropbox.
facebook
Package facebook implements the OAuth2 protocol for authenticating users through Facebook.
Package facebook implements the OAuth2 protocol for authenticating users through Facebook.
faux
Package faux is used exclusively for testing purposes.
Package faux is used exclusively for testing purposes.
github
Package github implements the OAuth2 protocol for authenticating users through Github.
Package github implements the OAuth2 protocol for authenticating users through Github.
gplus
Package gplus implements the OAuth2 protocol for authenticating users through Google+.
Package gplus implements the OAuth2 protocol for authenticating users through Google+.
lastfm
Package lastfm implements the OAuth protocol for authenticating users through LastFM.
Package lastfm implements the OAuth protocol for authenticating users through LastFM.
linkedin
Package linkedin implements the OAuth2 protocol for authenticating users through Linkedin.
Package linkedin implements the OAuth2 protocol for authenticating users through Linkedin.
spotify
Package spotify implements the OAuth protocol for authenticating users through Spotify.
Package spotify implements the OAuth protocol for authenticating users through Spotify.
twitch
Package twitch implements the OAuth2 protocol for authenticating users through Twitch.
Package twitch implements the OAuth2 protocol for authenticating users through Twitch.
twitter
Package twitter implements the OAuth protocol for authenticating users through Twitter.
Package twitter implements the OAuth protocol for authenticating users through Twitter.

Jump to

Keyboard shortcuts

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