コード例 #1
0
ファイル: oauth.go プロジェクト: speedland/rakugaki
func configureOAuth(routes *wcg.Router) {
	GoogleAuthConfig, _ := google.NewAuthConfigFromFile("")
	FacebookAuthConfig, _ := facebook.NewAuthConfigFromFile("")
	GoogleAuthConfig.RedirectURL = "/login/google/callback"
	GoogleAuthConfig.TransportFactory = gae.NewHttpTransport
	GoogleAuthConfig.UnauthorizedHandler = unauthorized
	GoogleAuthConfig.AuthorizedHandler = authorized
	GoogleAuthConfig.InvalidatedHandler = invalidated
	gauth, gcallback, gvalidates, glogout := middleware.OAuth2(GoogleAuthConfig)
	routes.All("/*", gvalidates)
	routes.Get("/login/google", gauth)
	routes.Get("/login/google/callback", gcallback)
	routes.Get("/logout/google", glogout)

	FacebookAuthConfig.RedirectURL = "/login/facebook/callback"
	FacebookAuthConfig.TransportFactory = gae.NewHttpTransport
	FacebookAuthConfig.UnauthorizedHandler = unauthorized
	FacebookAuthConfig.AuthorizedHandler = authorized
	FacebookAuthConfig.InvalidatedHandler = invalidated
	fbauth, fbcallback, fbvalidates, fblogout := middleware.OAuth2(FacebookAuthConfig)
	routes.All("/*", fbvalidates)
	routes.All("/*", func(res *wcg.Response, req *wcg.Request) {
		res.SetLocal("fb_app_id", FacebookAuthConfig.ClientId)
	})
	routes.Get("/login/facebook", fbauth)
	routes.Get("/login/facebook/callback", fbcallback)
	routes.Post("/logout/facebook", fblogout)
}
コード例 #2
0
ファイル: auth.go プロジェクト: speedland/apps
func facebookConfig() *middleware.OAuth2Config {
	cfg, _ := facebook.NewAuthConfigFromFile("")
	cfg.RedirectURL = "/login/facebook/callback"
	cfg.TransportFactory = gae.NewHttpTransport
	cfg.UnauthorizedHandler = unauthorizedHandler
	cfg.AuthorizedHandler = authorizedHandler
	cfg.InvalidatedHandler = invalidatedHandler
	cfg.Scope = ""
	return cfg
}