goth: github.com/markbates/goth Index | Files | Directories

package goth

import "github.com/markbates/goth"

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

Package Files

doc.go provider.go session.go user.go

Constants

const NoAuthUrlErrorMessage = "an AuthURL has not been set"

func ClearProviders Uses

func ClearProviders()

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

func ContextForClient Uses

func ContextForClient(h *http.Client) context.Context

ContextForClient provides a context for use with oauth2.

func HTTPClientWithFallBack Uses

func HTTPClientWithFallBack(h *http.Client) *http.Client

HTTPClientWithFallBack to be used in all fetch operations.

func UseProviders Uses

func UseProviders(viders ...Provider)

UseProviders adds a list of available providers for use with Goth. Can be called multiple times. If you pass the same provider more than once, the last will be used.

type Params Uses

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 Uses

type Provider interface {
    Name() string
    SetName(name string)
    BeginAuth(state string) (Session, error)
    UnmarshalSession(string) (Session, error)
    FetchUser(Session) (User, error)
    Debug(bool)
    RefreshToken(refreshToken string) (*oauth2.Token, error) //Get new access token based on the refresh token
    RefreshTokenAvailable() bool                             //Refresh token is provided by auth provider or not
}

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

func GetProvider Uses

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 Uses

type Providers map[string]Provider

Providers is list of known/available providers.

func GetProviders Uses

func GetProviders() Providers

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

type Session Uses

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 Uses

type User struct {
    RawData           map[string]interface{}
    Provider          string
    Email             string
    Name              string
    FirstName         string
    LastName          string
    NickName          string
    Description       string
    UserID            string
    AvatarURL         string
    Location          string
    AccessToken       string
    AccessTokenSecret string
    RefreshToken      string
    ExpiresAt         time.Time
}

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

PathSynopsis
examples
gothicPackage gothic wraps common behaviour when using Goth.
providers/amazonPackage amazon implements the OAuth2 protocol for authenticating users through amazon.
providers/auth0Package auth0 implements the OAuth2 protocol for authenticating users through uber.
providers/battlenetPackage battlenet implements the OAuth2 protocol for authenticating users through Battle.net.
providers/bitbucketPackage bitbucket implements the OAuth2 protocol for authenticating users through Bitbucket.
providers/boxPackage box implements the OAuth2 protocol for authenticating users through box.
providers/cloudfoundryPackage cloudfoundry implements the OAuth2 protocol for authenticating users through Cloud Foundry.
providers/dailymotionPackage dailymotion implements the OAuth2 protocol for authenticating users through Dailymotion.
providers/deezerPackage deezer implements the OAuth2 protocol for authenticating users through Deezer.
providers/digitaloceanPackage digitalocean implements the OAuth2 protocol for authenticating users through Digital Ocean.
providers/discordPackage discord implements the OAuth2 protocol for authenticating users through Discord.
providers/dropboxPackage dropbox implements the OAuth2 protocol for authenticating users through Dropbox.
providers/eveonlinePackage eveonline implements the OAuth2 protocol for authenticating users through eveonline.
providers/facebookPackage facebook implements the OAuth2 protocol for authenticating users through Facebook.
providers/fauxPackage faux is used exclusively for testing purposes.
providers/fitbitPackage fitbit implements the OAuth protocol for authenticating users through Fitbit.
providers/githubPackage github implements the OAuth2 protocol for authenticating users through Github.
providers/gitlabPackage gitlab implements the OAuth2 protocol for authenticating users through gitlab.
providers/gplusPackage gplus implements the OAuth2 protocol for authenticating users through Google+.
providers/herokuPackage heroku implements the OAuth2 protocol for authenticating users through heroku.
providers/influxcloudPackage influxdata implements the OAuth2 protocol for authenticating users through InfluxCloud.
providers/instagramPackage instagram implements the OAuth2 protocol for authenticating users through Instagram.
providers/intercomPackage intercom implements the OAuth protocol for authenticating users through Intercom.
providers/lastfmPackage lastfm implements the OAuth protocol for authenticating users through LastFM.
providers/linkedinPackage linkedin implements the OAuth2 protocol for authenticating users through Linkedin.
providers/meetupPackage meetup implements the OAuth2 protocol for authenticating users through meetup.com .
providers/onedrivePackage onedrive implements the OAuth2 protocol for authenticating users through onedrive.
providers/openidConnect
providers/paypalPackage paypal implements the OAuth2 protocol for authenticating users through paypal.
providers/salesforcePackage salesforce implements the OAuth2 protocol for authenticating users through salesforce.
providers/slackPackage slack implements the OAuth2 protocol for authenticating users through slack.
providers/soundcloudPackage soundcloud implements the OAuth2 protocol for authenticating users through soundcloud.
providers/spotifyPackage spotify implements the OAuth protocol for authenticating users through Spotify.
providers/steamPackage steam implements the OpenID protocol for authenticating users through Steam.
providers/stripePackage stripe implements the OAuth2 protocol for authenticating users through stripe.
providers/twitchPackage twitch implements the OAuth2 protocol for authenticating users through Twitch.
providers/twitterPackage twitter implements the OAuth protocol for authenticating users through Twitter.
providers/uberPackage uber implements the OAuth2 protocol for authenticating users through uber.
providers/wepayPackage wepay implements the OAuth2 protocol for authenticating users through wepay.
providers/xeroPackage xero implements the OAuth protocol for authenticating users through Xero.
providers/yahooPackage yahoo implements the OAuth2 protocol for authenticating users through yahoo.
providers/yammerPackage yammer implements the OAuth2 protocol for authenticating users through yammer.

Package goth imports 6 packages (graph) and is imported by 264 packages. Updated 2017-09-21. Refresh now. Tools for package owners.