Documentation ¶
Overview ¶
Package oauth package to manage extensions of the oauth protocol for oauth oAuthProviders
Package oauth package to manage extensions of the oauth protocol for oauth oAuthProviders ¶
Package oauth package to manage extensions of the oauth protocol for oauth oAuthProviders ¶
Package oauth package to manage extensions of the oauth protocol for oauth oAuthProviders
Index ¶
- Constants
- Variables
- func AuthorizeByService(w rest.ResponseWriter, r *rest.Request)
- func GetGithubConfig() *oauth2.Config
- func GetGitlabConfig() *oauth2.Config
- func GetGoogleConfig() *oauth2.Config
- func GithubAuthorize(redirectURI string, config *oauth2.Config, w rest.ResponseWriter, ...)
- func GitlabAuthorize(redirectURI string, config *oauth2.Config, w rest.ResponseWriter, ...)
- func GoogleAuthorize(redirectURI string, config *oauth2.Config, w rest.ResponseWriter, ...)
- type AuthorizeServiceFunc
- type CallbackServiceFunc
- type Config
- type GetServiceConfigFunc
- type ResponsePayload
- func CbByService(r *rest.Request) (*ResponsePayload, error)
- func GithubCb(ctx context.Context, config *oauth2.Config, code string) (*ResponsePayload, error)
- func GitlabCb(ctx context.Context, config *oauth2.Config, code string) (*ResponsePayload, error)
- func GoogleCb(ctx context.Context, config *oauth2.Config, code string) (*ResponsePayload, error)
- type ServiceType
Constants ¶
const ( // ServiceGoogle google service enum ServiceGoogle = ServiceType("google") // ServiceGithub github service enum ServiceGithub = ServiceType("github") // ServiceGitlab gitlab service enum ServiceGitlab = ServiceType("gitlab") )
Variables ¶
var ServicesAutorize = map[ServiceType]AuthorizeServiceFunc{ ServiceGoogle: GoogleAuthorize, ServiceGithub: GithubAuthorize, ServiceGitlab: GitlabAuthorize, }
ServicesAutorize get service config
var ServicesCallback = map[ServiceType]CallbackServiceFunc{ ServiceGoogle: GoogleCb, ServiceGithub: GithubCb, ServiceGitlab: GitlabCb, }
ServicesCallback callback process by service
var ServicesConfigs = map[ServiceType]GetServiceConfigFunc{ ServiceGoogle: GetGoogleConfig, ServiceGithub: GetGithubConfig, ServiceGitlab: GetGitlabConfig, }
ServicesConfigs get service config
Functions ¶
func AuthorizeByService ¶
func AuthorizeByService(w rest.ResponseWriter, r *rest.Request)
AuthorizeByService use service to autorize
func GetGithubConfig ¶
GetGithubConfig get configuration from return URL
func GetGitlabConfig ¶
GetGitlabConfig get configuration from return URL
func GetGoogleConfig ¶
GetGoogleConfig get configuration from return URL
func GithubAuthorize ¶
func GithubAuthorize(redirectURI string, config *oauth2.Config, w rest.ResponseWriter, r *rest.Request)
GithubAuthorize use google to authorize user
func GitlabAuthorize ¶
func GitlabAuthorize(redirectURI string, config *oauth2.Config, w rest.ResponseWriter, r *rest.Request)
GitlabAuthorize use google to authorize user
func GoogleAuthorize ¶
func GoogleAuthorize(redirectURI string, config *oauth2.Config, w rest.ResponseWriter, r *rest.Request)
GoogleAuthorize use google to authorize user
Types ¶
type AuthorizeServiceFunc ¶
type AuthorizeServiceFunc func(redirectURI string, config *oauth2.Config, w rest.ResponseWriter, r *rest.Request)
AuthorizeServiceFunc use service authorization method
type CallbackServiceFunc ¶
type CallbackServiceFunc func(ctx context.Context, config *oauth2.Config, code string) (*ResponsePayload, error)
CallbackServiceFunc use service authorization method
type GetServiceConfigFunc ¶
GetServiceConfigFunc get service configuration
type ResponsePayload ¶
type ResponsePayload struct { Nick string `json:"nick"` Email string `json:"email"` RedirectTo string `json:"redirect_uri"` Raw string `json:"raw"` Service ServiceType `json:"service_type"` }
ResponsePayload oauth response payload
func CbByService ¶
func CbByService(r *rest.Request) (*ResponsePayload, error)
CbByService use service callback