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 let's 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 ¶
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() (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 ¶
GetProvider returns a previously created provider. If Goth has not been told to use the named provider it will return an error.
type Providers ¶
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 back 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{} Email string Name string NickName string Description string UserID string AvatarURL string Location string AccessToken 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
|
|
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 exclusive for testing purposes.
|
Package faux is used exclusive for testing purposes. |
twitter
Package twitter implements the OAuth protocol for authenticating users through Twitter.
|
Package twitter implements the OAuth protocol for authenticating users through Twitter. |