2015-03-13 04:20:36 +02:00
|
|
|
package authboss
|
|
|
|
|
|
|
|
import (
|
2017-02-21 01:56:26 +02:00
|
|
|
"context"
|
2015-03-13 04:20:36 +02:00
|
|
|
"net/url"
|
|
|
|
|
2016-02-24 07:28:43 +02:00
|
|
|
"golang.org/x/oauth2"
|
2015-03-13 04:20:36 +02:00
|
|
|
)
|
|
|
|
|
2015-03-14 01:23:43 +02:00
|
|
|
/*
|
|
|
|
OAuth2Provider is the entire configuration
|
|
|
|
required to authenticate with this provider.
|
|
|
|
|
|
|
|
The OAuth2Config does not need a redirect URL because it will
|
2015-03-15 20:25:59 +02:00
|
|
|
be automatically created by the route registration in the oauth2 module.
|
2015-03-14 01:23:43 +02:00
|
|
|
|
|
|
|
AdditionalParams can be used to specify extra parameters to tack on to the
|
|
|
|
end of the initial request, this allows for provider specific oauth options
|
|
|
|
like access_type=offline to be passed to the provider.
|
|
|
|
|
2018-03-09 04:39:51 +02:00
|
|
|
FindUserDetails gives the config and the token allowing an http client using the
|
|
|
|
authenticated token to be created, a call is then made to a known endpoint that will
|
|
|
|
return details about the user we've retrieved the token for. Those details are returned
|
|
|
|
as a map[string]string and subsequently passed into OAuth2ServerStorer.NewFromOAuth2.
|
|
|
|
API this must be handled for each provider separately.
|
2015-03-14 01:23:43 +02:00
|
|
|
*/
|
2015-03-15 20:25:59 +02:00
|
|
|
type OAuth2Provider struct {
|
2015-03-13 04:20:36 +02:00
|
|
|
OAuth2Config *oauth2.Config
|
|
|
|
AdditionalParams url.Values
|
2018-03-09 04:39:51 +02:00
|
|
|
FindUserDetails func(context.Context, oauth2.Config, *oauth2.Token) (map[string]string, error)
|
2015-03-13 04:20:36 +02:00
|
|
|
}
|