本文整理汇总了Golang中github.com/stretchr/gomniauth/providers/github.New函数的典型用法代码示例。如果您正苦于以下问题:Golang New函数的具体用法?Golang New怎么用?Golang New使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了New函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: main
func main() {
var addr = flag.String("addr", ":8080", "アプリケーションのアドレス")
flag.Parse() // フラグを解釈します
// Gomniauthのセットアップ
gomniauth.SetSecurityKey("セキュリティキー")
gomniauth.WithProviders(
facebook.New("クライアントID", "秘密の値", "http://localhost:8080/auth/callback/facebook"),
github.New("クライアントID", "秘密の値", "http://localhost:8080/auth/callback/github"),
google.New("クライアントID", "秘密の値", "http://localhost:8080/auth/callback/google"),
)
r := newRoom()
r.tracer = trace.New(os.Stdout)
http.Handle("/chat", MustAuth(&templateHandler{filename: "chat.html"}))
http.Handle("/login", &templateHandler{filename: "login.html"})
http.HandleFunc("/auth/", loginHandler)
http.Handle("/room", r)
// チャットルームを開始します
go r.run()
// Webサーバーを起動します
log.Println("Webサーバーを開始します。ポート: ", *addr)
if err := http.ListenAndServe(*addr, nil); err != nil {
log.Fatal("ListenAndServe:", err)
}
}
开发者ID:ukai,项目名称:go-programming-blueprints,代码行数:25,代码来源:main.go
示例2: Initialize
// Initialize collects server-side credential from environment variables and prepare for authentication with Github OAuth.
//
// Client authentication is disabled and CurrentUser always returns "anonymous" if any of the environment variables are missing.
func Initialize(anynomous User, cookieSecret []byte) {
store = sessions.NewCookieStore(cookieSecret)
githubCallbackBase = os.Getenv("GITHUB_CALLBACK_URL")
cred := struct {
githubRandomHashKey string
githubOmniauthID string
githubOmniauthKey string
}{
os.Getenv("GITHUB_RANDOM_HASH_KEY"),
os.Getenv("GITHUB_OMNI_AUTH_ID"),
os.Getenv("GITHUB_OMNI_AUTH_KEY"),
}
defaultUser = anynomous
if cred.githubRandomHashKey == "" || cred.githubOmniauthID == "" || cred.githubOmniauthKey == "" || githubCallbackBase == "" {
glog.Warningf(
"Missing one or more Gomniauth Environment Variables: Running with with limited functionality! \n GITHUB_RANDOM_HASH_KEY [%s] \n GITHUB_OMNI_AUTH_ID [%s] \n GITHUB_OMNI_AUTH_KEY [%s] \n GITHUB_CALLBACK_URL [%s]",
cred.githubRandomHashKey,
cred.githubOmniauthID,
cred.githubOmniauthKey,
githubCallbackBase,
)
enabled = false
return
}
url := fmt.Sprintf("%s/auth/github/callback", githubCallbackBase)
gomniauth.SetSecurityKey(cred.githubRandomHashKey)
gomniauth.WithProviders(
githubOauth.New(cred.githubOmniauthID, cred.githubOmniauthKey, url),
)
glog.Infof("Enabled authentication by github OAuth2")
enabled = true
}
开发者ID:kgrvamsi,项目名称:goship,代码行数:37,代码来源:auth.go
示例3: main
func main() {
addr := flag.String("addr", ":8080", "address")
flag.Parse()
gomniauth.SetSecurityKey("key")
gomniauth.WithProviders(
github.New("clientid", "secretkey", "http://localhost:8080/auth/callback/github"),
)
http.HandleFunc("/1/0", func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("hoge"))
})
http.Handle("/1/1", &templateHandler{filename: "chat.html"})
http.Handle("/2/1", MustAuth(&templateHandler{filename: "chat.html"}))
http.Handle("/login", &templateHandler{filename: "login.html"})
http.HandleFunc("/auth", loginHandler)
r := newRoom()
r.tracer = trace.New(os.Stdout)
http.Handle("/1/2", r)
go r.run()
if err := http.ListenAndServe(*addr, nil); err != nil {
log.Fatal("ListenAndServe:", err)
}
}
开发者ID:ntk1000,项目名称:go-web-book-playground,代码行数:26,代码来源:main.go
示例4: main
func main() {
var addr = flag.String("addr", ":8080", "The addr of the application.")
// set up gomniauth
gomniauth.SetSecurityKey("lfq618")
gomniauth.WithProviders(
facebook.New("608517422619964", "ff3966474a0e0925419a57cd79776bdd", "http://localhost:8080/auth/callback/facebook"),
github.New("6f6ab375ab58c83ce223", "20e565a7e13d235c60ede23a26d33bd8a735e03a", "http://localhost:8080/auth/callback/github"),
google.New("507301202565-k1drgkq7v6u5b42fk849k90pm33b3van.apps.googleusercontent.com", "EmPZvBUVc1-Tc5fWQ4gjSh78", "http://localhost:8080/auth/callback/google"),
)
r := newRoom()
//r.tracer = trace.New(os.Stdout)
//root
http.Handle("/chat", MustAuth(&templateHandler{filename: "chat.html"}))
http.Handle("/login", &templateHandler{filename: "login.html"})
http.HandleFunc("/auth/", loginHandler)
http.Handle("/room", r)
//get the room goint
go r.run()
//start the web server
log.Println("Starting web server on", *addr)
if err := http.ListenAndServe(*addr, nil); err != nil {
log.Fatal("ListenAndServe:", err)
}
}
开发者ID:lfq618,项目名称:golearn,代码行数:28,代码来源:main.go
示例5: Initialize
// Initialize collects server-side credential from environment variables and prepare for authentication with Github OAuth.
//
// Client authentication is disabled and CurrentUser always returns "anonymous" if any of the environment variables are missing.
func Initialize(anynomous User, cookieSecret []byte) {
store = sessions.NewCookieStore(cookieSecret)
githubCallbackURL = os.Getenv("GITHUB_CALLBACK_URL")
cred := struct {
githubRandomHashKey string
githubOmniauthID string
githubOmniauthKey string
}{
os.Getenv("GITHUB_RANDOM_HASH_KEY"),
os.Getenv("GITHUB_OMNI_AUTH_ID"),
os.Getenv("GITHUB_OMNI_AUTH_KEY"),
}
defaultUser = anynomous
if cred.githubRandomHashKey == "" || cred.githubOmniauthID == "" || cred.githubOmniauthKey == "" || githubCallbackURL == "" {
log.Printf(
"Missing one or more Gomniauth Environment Variables: Running with with limited functionality! \n githubRandomHashKey [%s] \n githubOmniauthID [%s] \n githubOmniauthKey[%s] \n githubCallbackURL[%s]",
cred.githubRandomHashKey,
cred.githubOmniauthID,
cred.githubOmniauthKey,
githubCallbackURL,
)
enabled = false
return
}
githubCallbackURL = path.Join(githubCallbackURL, "/auth/github/callback")
gomniauth.SetSecurityKey(cred.githubRandomHashKey)
gomniauth.WithProviders(
githubOauth.New(cred.githubOmniauthID, cred.githubOmniauthKey, githubCallbackURL),
)
enabled = true
}
开发者ID:cazacugmihai,项目名称:goship,代码行数:36,代码来源:auth.go
示例6: main
func main() {
flag.Parse() // parse the flags
// setup gomniauth
gomniauth.SetSecurityKey("98dfbg7iu2nb4uywevihjw4tuiyub34noilk")
gomniauth.WithProviders(
github.New("3d1e6ba69036e0624b61", "7e8938928d802e7582908a5eadaaaf22d64babf1", "http://localhost:8080/auth/callback/github"),
google.New("44166123467-o6brs9o43tgaek9q12lef07bk48m3jmf.apps.googleusercontent.com", "rpXpakthfjPVoFGvcf9CVCu7", "http://localhost:8080/auth/callback/google"),
facebook.New("537611606322077", "f9f4d77b3d3f4f5775369f5c9f88f65e", "http://localhost:8080/auth/callback/facebook"),
)
r := newRoom()
r.tracer = trace.New(os.Stdout)
http.Handle("/chat", MustAuth(&templateHandler{filename: "chat.html"}))
http.Handle("/login", &templateHandler{filename: "login.html"})
http.HandleFunc("/auth/", loginHandler)
http.Handle("/room", r)
// get the room going
go r.run()
// start the web server
log.Println("Starting web server on", *host)
if err := http.ListenAndServe(*host, nil); err != nil {
log.Fatal("ListenAndServe:", err)
}
}
开发者ID:0-T-0,项目名称:goblueprints,代码行数:30,代码来源:main.go
示例7: main
func main() {
var addr = flag.String("addr", ":8080", "The addr of the application.")
flag.Parse() // parse the flags
gomniauth.SetSecurityKey("some long key")
gomniauth.WithProviders(
facebook.New("key", "secret", "http://localhost:8080/auth/callback/facebook"),
github.New("key", "secret", "http://localhost:8080/auth/callback/github"),
google.New("key", "secret", "http://localhost:8080/auth/callback/google"),
)
r := newRoom()
r.tracer = trace.New(os.Stdout)
http.Handle("/chat", MustAuth(&templateHandler{filename: "chat.html"}))
http.Handle("/login", &templateHandler{filename: "login.html"})
http.HandleFunc("/auth/", loginHandler)
http.Handle("/room", r)
// get the room going
go r.run()
// start the web server
log.Println("Starting web server on", *addr)
if err := http.ListenAndServe(*addr, nil); err != nil {
log.Fatal("ListenAndServe:", err)
}
}
开发者ID:jplesperance,项目名称:go-learning-projects,代码行数:27,代码来源:main.go
示例8: main
func main() {
var addr = flag.String("addr", ":8080", "The addr of the application.")
flag.Parse()
gomniauth.SetSecurityKey(os.Getenv("GOCHAT_SEC_KEY"))
gomniauth.WithProviders(
soundcloud.New(os.Getenv("ENV_SC_CLIENT_ID"), os.Getenv("ENV_SC_SECRET"), os.Getenv("ENV_SC_CALLBACK_URL")),
github.New(os.Getenv("ENV_GH_CLIENT_ID"), os.Getenv("ENV_GH_SECRET"), os.Getenv("ENV_GH_CALLBACK_URL")),
)
r := newRoom(UseGravatar)
r.tracer = trace.New(os.Stdout)
http.Handle("/chat", MustAuth(&templateHandler{filename: "chat.html"}))
http.Handle("/login", &templateHandler{filename: "login.html"})
http.HandleFunc("/logout", logoutHandler)
http.HandleFunc("/auth/", loginHandler)
http.Handle("/room", r)
http.Handle("/upload", &templateHandler{filename: "upload.html"})
http.HandleFunc("/uploader", uploaderHandler)
http.Handle("/avatars/",
http.StripPrefix("/avatars/",
http.FileServer(http.Dir("./avatars/"))))
go r.run()
log.Println("Starting web server on ", *addr)
if err := http.ListenAndServe(*addr, nil); err != nil {
log.Fatal("ListenAndServe:", err)
}
}
开发者ID:mxjxn,项目名称:gochat,代码行数:33,代码来源:main.go
示例9: main
func main() {
var addr = flag.String("addr", ":18080", "アプリケーションのアドレス")
flag.Parse() // フラグを解釈します
// Gomniauth のセットアップ
gomniauth.SetSecurityKey("RESIDENCE101")
gomniauth.WithProviders(
facebook.New("957653387645069", "bd4b9984868d78cb2012b4554a6c61a8", "http://localhost:18080/auth/callback/facebook"),
github.New("60c22ff289a776f58746", "cd1581d547e80cfc01586bdfd343317a8b9e3f65", "http://localhost:18080/auth/callback/github"),
google.New("940801949020-9b6d4r5emh1k6ds9mmmiq1esdt669mrs.apps.googleusercontent.com", "jd3H38hVee1Ragcx0UzStHoW", "http://localhost:18080/auth/callback/google"),
)
r := newRoom()
http.Handle("/chat", MustAuth(&templateHandler{filename: "chat.html"}))
http.Handle("/login", &templateHandler{filename: "login.html"})
http.HandleFunc("/auth/", loginHandler)
http.Handle("/room", r)
// チャットルームを開始します
go r.run()
// Web サーバーを開始します
log.Println("Web サーバーを開始します。ポート: ", *addr)
if err := http.ListenAndServe(*addr, nil); err != nil {
log.Fatal("ListenAndServe:", err)
}
}
开发者ID:masutaka,项目名称:goblueprints,代码行数:27,代码来源:main.go
示例10: getAuth
// Authenticate with Github. If env data is missing turn Auth off.
func getAuth() auth {
a := auth{}
a.githubRandomHashKey = os.Getenv("GITHUB_RANDOM_HASH_KEY")
a.githubOmniauthID = os.Getenv("GITHUB_OMNI_AUTH_ID")
a.githubOmniauthKey = os.Getenv("GITHUB_OMNI_AUTH_KEY")
a.githubCallbackURL = os.Getenv("GITHUB_CALLBACK_URL")
// Let user know if a key is missing and that auth is disabled.
if a.githubRandomHashKey == "" || a.githubOmniauthID == "" || a.githubOmniauthKey == "" || a.githubCallbackURL == "" {
log.Printf("Missing one or more Gomniauth Environment Variables: Running with with limited functionality! \n githubRandomHashKey [%s] \n githubOmniauthID [%s] \n githubOmniauthKey[%s] \n githubCallbackURL[%s]",
a.githubRandomHashKey,
a.githubOmniauthID,
a.githubOmniauthKey,
a.githubCallbackURL)
a.authorization = false
return a
}
gomniauth.SetSecurityKey(a.githubRandomHashKey)
gomniauth.WithProviders(
githubOauth.New(a.githubOmniauthID, a.githubOmniauthKey, a.githubCallbackURL+"/auth/github/callback"),
)
a.authorization = true
return a
}
开发者ID:cinderalla,项目名称:goship,代码行数:26,代码来源:goship.go
示例11: main
func main() {
// The de nition for the addr variable sets up our flag
// as a string that defaults to :8080
addr := flag.String("addr", ":8080", "The addr of the application.")
// must call flag. Parse() that parses the arguments
// and extracts the appropriate information.
// Then, we can reference the value of the host ag by using *addr.
flag.Parse() // parse the flags
// set up gomniauth
gomniauth.SetSecurityKey("some long key")
gomniauth.WithProviders(
facebook.New("key", "secret", ""),
github.New("key", "secret", ""),
google.New("151570833065-i9p63mogjm7adt0h0490or9bvqua0r2l.apps.googleusercontent.com",
"jzEEORYarixD30S6qyosGrWe",
"http://localhost:3000/auth/callback/google"),
)
// r := newRoom(UseAuthAvatar)
// r := newRoom(UseGravatar)
r := newRoom(UseFileSystemAvatar)
r.tracer = trace.New(os.Stdout)
http.Handle("/chat", MustAuth(&templateHandler{filename: "chat.html"}))
http.Handle("/login", &templateHandler{filename: "login.html"})
http.HandleFunc("/auth/", loginHandler)
http.Handle("/room", r)
http.HandleFunc("/logout", func(w http.ResponseWriter, r *http.Request) {
http.SetCookie(w, &http.Cookie{
Name: "auth",
Value: "",
Path: "/",
MaxAge: -1,
})
w.Header()["Location"] = []string{"/chat"}
w.WriteHeader(http.StatusTemporaryRedirect)
})
http.Handle("/upload", &templateHandler{filename: "upload.html"})
http.HandleFunc("/uploader", uploaderHandler)
http.Handle("/avatars/",
http.StripPrefix("chapter2/chat/avatars/",
http.FileServer(http.Dir("./avatars"))))
// get the room going
// running the room in a separate Go routine
// so that the chatting operations occur in the background,
// allowing our main thread to run the web server.
go r.run()
// start the web server
log.Println("Starting web server on", *addr)
// start the web server
if err := http.ListenAndServe(*addr, nil); err != nil {
log.Fatal("ListenAndServe:", err)
}
}
开发者ID:rabbitcount,项目名称:goblueprints,代码行数:56,代码来源:main.go
示例12: main
func main() {
var addr = flag.String("addr", ":8080", "The addr of the application.")
flag.Parse() // parse the flags
// set up gomniauth
gomniauth.SetSecurityKey("amazing2050")
gomniauth.WithProviders(
facebook.New("key", "secret", "http://localhost:8080/auth/callback/facebook"),
github.New("key", "secret", "http://localhost:8080/auth/callback/github"),
google.New("638547583987-2l7p38d7iq7kpp2rvvms4ambvg1qaq5b.apps.googleusercontent.com", "whS4UlWsA0YXRdD7nVQScrcK", "http://localhost:8080/auth/callback/google"),
)
r := newRoom()
r.tracer = trace.New(os.Stdout)
// handlers
http.Handle("/chat", MustAuth(&templateHandler{filename: "chat.html"}))
http.Handle("/login", &templateHandler{filename: "login.html"})
http.HandleFunc("/auth/", loginHander)
http.Handle("/room", r)
http.Handle("/upload", MustAuth(&templateHandler{filename: "upload.html"}))
http.HandleFunc("/uploader", uploaderHandler)
// both http.StripPrefix and http.FileServer return Handler and they
// use the decorator pattern
// The StripPrefix function takes Handler in, modifies the path by removing
// the specified prefix, and passes functionality onto an inner handler.
// The FileServer handler simply serve static files, and generating the
// 404 Not Fount error if it cannot find the file.
http.Handle("/avatars/",
http.StripPrefix("/avatars/",
http.FileServer(http.Dir("./avatars"))))
http.HandleFunc("/logout", func(w http.ResponseWriter, r *http.Request) {
http.SetCookie(w, &http.Cookie{
Name: "auth",
Value: "",
Path: "/",
MaxAge: -1,
})
w.Header()["Location"] = []string{"/chat"}
w.WriteHeader(http.StatusTemporaryRedirect)
})
// get the room going
go r.run()
// start the web server
log.Println("Starting web server on", *addr)
if err := http.ListenAndServe(*addr, nil); err != nil {
log.Fatal("ListenAndServe:", err)
}
}
开发者ID:liyu-wang,项目名称:go-chat,代码行数:50,代码来源:main.go
示例13: main
func main() {
secretKey := "kyokomi-secret"
gomniauth.SetSecurityKey(secretKey)
gomniauth.WithProviders(
github.New(githubClientID, githubSecretKey, githubRedirectURL),
google.New(googleClientID, googleSecretKey, googleRedirectURL),
)
kami.Get("/", indexHandler)
kami.Get("/auth/login/:provider", loginHandler)
kami.Get("/auth/callback/:provider", callbackHandler)
kami.Serve()
}
开发者ID:kyokomi-sandbox,项目名称:sandbox,代码行数:15,代码来源:gomniauth.go
示例14: main
func main() {
addr := flag.String("addr", ":8080", "An address of application")
flag.Parse()
config := loadConfig()
gomniauth.SetSecurityKey("セキュリティキー")
gomniauth.WithProviders(
facebook.New(
config.Facebook.ClientID,
config.Facebook.ClientSecret,
"http://localhost:8080/auth/callback/facebook",
),
github.New(
config.Github.ClientID,
config.Github.ClientSecret,
"http://localhost:8080/auth/callback/github",
),
google.New(
config.Google.ClientID,
config.Google.ClientSecret,
"http://localhost:8080/auth/callback/google",
),
)
r := newRoom(UseGravatar)
http.Handle("/chat", MustAuth(&templateHandler{filename: "chat.html"}))
http.Handle("/login", &templateHandler{filename: "login.html"})
http.HandleFunc("/auth/", loginHandler)
http.Handle("/room", r)
http.HandleFunc("/logout", func(w http.ResponseWriter, r *http.Request) {
http.SetCookie(w, &http.Cookie{
Name: "auth",
Value: "",
Path: "/",
MaxAge: -1,
})
w.Header()["Location"] = []string{"/chat"}
w.WriteHeader(http.StatusTemporaryRedirect)
})
http.Handle("/upload", &templateHandler{filename: "upload.html"})
http.HandleFunc("/uploader", uploadHandler)
go r.run()
log.Println("start web server. port: ", *addr)
if err := http.ListenAndServe(*addr, nil); err != nil {
log.Fatal("ListenAndServe:", err)
}
}
开发者ID:pirosikick,项目名称:go-api-example,代码行数:48,代码来源:main.go
示例15: main
func main() {
var addr = flag.String("addr", ":8080", "アプリケーションのアドレス")
flag.Parse()
c, err := redis.Dial("tcp", ":6379")
if err != nil {
fmt.Println(err)
return
}
defer c.Close()
log.Println("Redisにせつぞくしました。")
gomniauth.SetSecurityKey(os.Getenv("FUNNYCHAT_SECURITY_KEY"))
gomniauth.WithProviders(
facebook.New(os.Getenv("FB_CLIENT_ID"), os.Getenv("FB_SECRET_KEY"), "http://localhost:8080/auth/callback/facebook"),
google.New(os.Getenv("GOOGLE_CLIENT_ID"), os.Getenv("GOOGLE_SECRET_KEY"), "http://localhost:8080/auth/callback/google"),
github.New(os.Getenv("GITHUB_CLIENT_ID"), os.Getenv("GITHUB_SECRET_KEY"), "http://localhost:8080/auth/callback/github"),
)
r := newRoom(c)
r.subscribe("room01")
r.tracer = trace.New(os.Stdout)
http.Handle("/chat", MustAuth(&templateHandler{filename: "chat.html"}))
http.Handle("/login", &templateHandler{filename: "login.html"})
http.HandleFunc("/auth/", loginHandler)
http.HandleFunc("/logout", func(w http.ResponseWriter, r *http.Request) {
http.SetCookie(w, &http.Cookie{
Name: "auth",
Value: "",
Path: "/",
MaxAge: -1,
})
w.Header()["Location"] = []string{"/chat"}
w.WriteHeader(http.StatusTemporaryRedirect)
})
http.Handle("/room", r)
http.Handle("/upload", &templateHandler{filename: "upload.html"})
http.HandleFunc("/uploader", uploadHandler)
http.Handle("/avatars/", http.StripPrefix("/avatars/", http.FileServer(http.Dir("./avatars"))))
http.Handle("/assets/", http.StripPrefix("/assets", http.FileServer(http.Dir("assets"))))
go r.run()
go r.receive()
log.Println("Webサーバーを開始します。ポート: ", *addr)
if err := http.ListenAndServe(*addr, nil); err != nil {
log.Fatal("ListenAndServe:", err)
}
}
开发者ID:keito-jp,项目名称:chat,代码行数:48,代码来源:main.go
示例16: main
func main() {
var addr = flag.String("addr", ":8080", "The addr of the application.")
flag.Parse() // parse the flags
// set up gomniauth
gomniauth.SetSecurityKey("this is my own crazy phrase not")
gomniauth.WithProviders(
facebook.New("key", "secret", "http://localhost:8080/auth/callback/facebook"),
github.New("key", "secret", "http://localhost:8080/auth/callback/github"),
google.New("AIzaSyAHdC_P8iM2SU3D5BEh5747tGb4Sr5xxj8", "3aoJeQ8Ub3l2Gfvz-wNIOXUo", "http://localhost:8080/auth/callback/google"),
)
r := newRoom()
// output to the os.Stdout standard output pipe (prints output to the terminal)
//r.tracer = trace.New(os.Stdout)
// root
http.Handle("/chat", MustAuth(&templateHandler{filename: "chat.html"}))
http.Handle("/login", &templateHandler{filename: "login.html"})
http.HandleFunc("/auth/", loginHandler)
http.Handle("/room", r)
// Directory used to store css and js files.
//http.Handle("/assets/",
// http.StripPrefix("/assets",
// http.FileServer(http.Dir("/path/to/assets/"))))
// get the room going
go r.run()
// Writes out the hardcoded HTML when a request is made
/*http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte(`
<html>
<head>
<title>Chat</title>
</head>
<body>
Let's chat!
</body>
</html>
`))
})*/
// Starts web server using ListenAndServe
log.Println("Starting web server on", *addr)
if err := http.ListenAndServe(":8080", nil); err != nil {
log.Fatal("ListenAndServe:", err)
}
}
开发者ID:mufniarz,项目名称:Go-Web-Project,代码行数:46,代码来源:main.go
示例17: main
func main() {
flag.Parse() // parse the flags
// setup gomniauth
gomniauth.SetSecurityKey("98dfbg7iu2nb4uywevihjw4tuiyub34noilk")
gomniauth.WithProviders(
github.New("3d1e6ba69036e0624b61", "7e8938928d802e7582908a5eadaaaf22d64babf1", "http://localhost:8080/auth/callback/github"),
google.New("44166123467-o6brs9o43tgaek9q12lef07bk48m3jmf.apps.googleusercontent.com", "rpXpakthfjPVoFGvcf9CVCu7", "http://localhost:8080/auth/callback/google"),
facebook.New("537611606322077", "f9f4d77b3d3f4f5775369f5c9f88f65e", "http://localhost:8080/auth/callback/facebook"),
)
r := newRoom()
r.tracer = trace.New(os.Stdout)
http.Handle("/chat", MustAuth(&templateHandler{filename: "chat.html"}))
http.Handle("/login", &templateHandler{filename: "login.html"})
http.HandleFunc("/auth/", loginHandler)
http.Handle("/room", r)
http.HandleFunc("/logout", func(w http.ResponseWriter, r *http.Request) {
http.SetCookie(w, &http.Cookie{
Name: "auth",
Value: "",
Path: "/",
MaxAge: -1,
})
w.Header().Set("Location", "/chat")
w.WriteHeader(http.StatusTemporaryRedirect)
})
http.Handle("/upload", &templateHandler{filename: "upload.html"})
http.HandleFunc("/uploader", uploaderHandler)
http.Handle("/avatars/",
http.StripPrefix("/avatars/",
http.FileServer(http.Dir("./avatars"))))
// get the room going
go r.run()
// start the web server
log.Println("Starting web server on", *host)
if err := http.ListenAndServe(*host, nil); err != nil {
log.Fatal("ListenAndServe:", err)
}
}
开发者ID:yanai-masahiro,项目名称:goblueprints,代码行数:46,代码来源:main.go
示例18: main
func main() {
var addr = flag.String("addr", ":3000", "The addr of the application")
flag.Parse()
// set up gomniauth
gomniauth.SetSecurityKey("some long key")
gomniauth.WithProviders(
facebook.New("key", "secret",
"http://localhost:3000/auth/callback/facebook"),
github.New("key", "secret",
"http://localhost:3000/auth/callback/github"),
google.New("89198476902-sp9n6ukjk37ccc2vuh11chkga865sidq.apps.googleusercontent.com", "GeQA1wriK2DdN_tTg8Sv1x9r",
"http://localhost:3000/auth/callback/google"),
)
r := newRoom(UseAuthAvatar)
http.HandleFunc("/room", r.serveHTTP)
mainTemplate := &templateHandler{filename: "chat.html", messages: r.Messages}
loginTemplate := &templateHandler{filename: "login.html"}
http.HandleFunc("/auth/", LoginHandler)
http.HandleFunc("/chat", MustAuth(mainTemplate).ServeHTTP)
http.HandleFunc("/login", loginTemplate.ServeHTTP)
http.HandleFunc("/logout", func(w http.ResponseWriter, r *http.Request) {
http.SetCookie(w, &http.Cookie{
Name: "auth",
Value: "",
Path: "/",
MaxAge: -1,
})
w.Header()["Location"] = []string{"/chat"}
w.WriteHeader(http.StatusTemporaryRedirect)
})
go r.run()
log.Println("Server starting on ", *addr)
err := http.ListenAndServe(*addr, nil)
if err != nil {
log.Fatal("ListenAndServe: ", err)
}
}
开发者ID:NikitaSmall,项目名称:gochat,代码行数:44,代码来源:main.go
示例19: main
func main() {
// setup the providers
gomniauth.SetSecurityKey("yLiCQYG7CAflDavqGH461IO0MHp7TEbpg6TwHBWdJzNwYod1i5ZTbrIF5bEoO3oP") // NOTE: DO NOT COPY THIS - MAKE YOR OWN!
gomniauth.WithProviders(
github.New("3d1e6ba69036e0624b61", "7e8938928d802e7582908a5eadaaaf22d64babf1", "http://localhost:8080/auth/github/callback"),
google.New("1051709296778.apps.googleusercontent.com", "7oZxBGwpCI3UgFMgCq80Kx94", "http://localhost:8080/auth/google/callback"),
facebook.New("537611606322077", "f9f4d77b3d3f4f5775369f5c9f88f65e", "http://localhost:8080/auth/facebook/callback"),
)
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
template := `
<!DOCTYPE html>
<html>
<body>
<h2>Log in with...</h2>
<ul>
<li>
<a href="auth/github/login">GitHub</a>
</li>
<li>
<a href="auth/google/login">Google</a>
</li>
<li>
<a href="auth/facebook/login">Facebook</a>
</li>
</ul>
</body>
</html>
`
io.WriteString(w, template)
})
providers := []string{"google", "github", "facebook"}
for _, provider := range providers {
http.HandleFunc(fmt.Sprintf("/auth/%s/login", provider), loginHandler(provider))
http.HandleFunc(fmt.Sprintf("/auth/%s/callback", provider), callbackHandler(provider))
}
http.ListenAndServe(Address, nil)
}
开发者ID:amencarini,项目名称:gomniauth,代码行数:42,代码来源:main.go
示例20: main
func main() {
var addr = flag.String("addr", ":8080", "The addr of the application.")
// set up gomniauth
gomniauth.SetSecurityKey("lfq618")
gomniauth.WithProviders(
facebook.New("608517422619964", "ff3966474a0e0925419a57cd79776bdd", "http://localhost:8080/auth/callback/facebook"),
github.New("6f6ab375ab58c83ce223", "20e565a7e13d235c60ede23a26d33bd8a735e03a", "http://localhost:8080/auth/callback/github"),
google.New("507301202565-k1drgkq7v6u5b42fk849k90pm33b3van.apps.googleusercontent.com", "EmPZvBUVc1-Tc5fWQ4gjSh78", "http://localhost:8080/auth/callback/google"),
)
r := newRoom()
//r.tracer = trace.New(os.Stdout)
//root
http.Handle("/chat", MustAuth(&templateHandler{filename: "chat.html"}))
http.Handle("/login", &templateHandler{filename: "login.html"})
http.Handle("/upload", &templateHandler{filename: "upload.html"})
http.HandleFunc("/uploader", uploaderHandler)
http.HandleFunc("/auth/", loginHandler)
http.HandleFunc("/logout", func(w http.ResponseWriter, r *http.Request) {
http.SetCookie(w, &http.Cookie{
Name: "auth",
Value: "",
Path: "/",
MaxAge: -1,
})
w.Header()["Location"] = []string{"/chat"}
w.WriteHeader(http.StatusTemporaryRedirect)
})
http.Handle("/room", r)
http.Handle("/avatars/", http.StripPrefix("/avatars/", http.FileServer(http.Dir("./avatars"))))
//get the room goint
go r.run()
//start the web server
log.Println("Starting web server on", *addr)
if err := http.ListenAndServe(*addr, nil); err != nil {
log.Fatal("ListenAndServe:", err)
}
}
开发者ID:lfq618,项目名称:golearn,代码行数:41,代码来源:main.go
注:本文中的github.com/stretchr/gomniauth/providers/github.New函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论