Documentation
¶
Index ¶
- func Authenticate(cfg *Config, w http.ResponseWriter, r *http.Request) (model.UserInfo, error)
- func ConstructorList() []string
- func GetConstructor(name string) func(cfg *Config) goth.Provider
- func Logout(res http.ResponseWriter, req *http.Request) error
- func ProviderList() []string
- func Register(name string, newi func(cfg *Config) goth.Provider)
- func SetCookieStore(secret string)
- func SetSessionStore(store sessions.Store)
- func StartFlow(cfg *Config, w http.ResponseWriter, r *http.Request) error
- type Config
- func (cfg *Config) GetProvider() goth.Provider
- func (cfg *Config) GetRedirectURI() string
- func (cfg *Config) GetScopes() []string
- func (cfg *Config) InitProvider() error
- func (cfg *Config) NewProvider() (p goth.Provider, err error)
- func (cfg *Config) SetProvider(provider goth.Provider) *Config
- func (cfg *Config) SetRedirectURI(redirectURI string) *Config
- type Manager
- func (manager *Manager) AddConfig(providerName string, opts map[string]string) error
- func (manager *Manager) GetConfigFromRequest(r *http.Request) (*Config, error)
- func (manager *Manager) GetConfigs() map[string]*Config
- func (manager *Manager) Handle(w http.ResponseWriter, r *http.Request) (startedFlow bool, authenticated bool, userInfo model.UserInfo, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Authenticate ¶
Authenticate after coming back from the oauth flow. Verify the state parameter againt the state cookie from the request.
func ConstructorList ¶
func ConstructorList() []string
ConstructorList returns the names of all registered constructor
func Logout ¶
func Logout(res http.ResponseWriter, req *http.Request) error
Logout invalidates a user session.
func ProviderList ¶
func ProviderList() []string
ProviderList returns the names of all registered provider
func SetCookieStore ¶
func SetCookieStore(secret string)
func SetSessionStore ¶
Types ¶
type Config ¶
type Config struct { // ClientID is the application's ID. ClientID string // ClientSecret is the application's secret. ClientSecret string // RedirectURL is the URL to redirect users going through // the OAuth flow, after the resource owner's URLs. RedirectURI string // Scope specifies optional requested permissions, this is a *space* separated list. Scope string Extra map[string]string // The oauth provider Provider goth.Provider ProviderName string // contains filtered or unexported fields }
Config describes a typical 3-legged OAuth2 flow, with both the client application information and the server's endpoint URLs.
func (*Config) GetProvider ¶
func (*Config) GetRedirectURI ¶ added in v0.1.5
func (*Config) InitProvider ¶
func (*Config) SetRedirectURI ¶ added in v0.1.5
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager has the responsibility to handle the user user requests in an oauth flow. It has to pick the right configuration and start the oauth redirecting.
func (*Manager) GetConfigFromRequest ¶
GetConfigFromRequest returns the oauth configuration matching the current path. The configuration name is taken from the last path segment.
func (*Manager) GetConfigs ¶
GetConfigs of the manager
func (*Manager) Handle ¶
func (manager *Manager) Handle(w http.ResponseWriter, r *http.Request) ( startedFlow bool, authenticated bool, userInfo model.UserInfo, err error)
Handle is managing the oauth flow. Dependent on the code parameter of the url, the oauth flow is started or the call is interpreted as the redirect callback and the token exchange is done. Return parameters:
startedFlow - true, if this was the initial call to start the oauth flow authenticated - if the authentication was successful or not userInfo - the user info from the provider in case of a successful authentication err - an error