diff options
author | Unknown <joe2010xtmf@163.com> | 2014-04-05 11:22:14 -0400 |
---|---|---|
committer | Unknown <joe2010xtmf@163.com> | 2014-04-05 11:22:14 -0400 |
commit | 3ebc9b991a70e10c4b2c6319c1ff6195c0d75a17 (patch) | |
tree | 0ba3e63a6f24bbba576b2a25b8f9b52e5205ec10 /web.go | |
parent | 9791e70da67091d244728070b80ee92c98d6aa8b (diff) | |
download | gitea-3ebc9b991a70e10c4b2c6319c1ff6195c0d75a17.tar.gz gitea-3ebc9b991a70e10c4b2c6319c1ff6195c0d75a17.zip |
Use gogits/session for oauth2
Diffstat (limited to 'web.go')
-rw-r--r-- | web.go | 23 |
1 files changed, 10 insertions, 13 deletions
@@ -11,8 +11,6 @@ import ( "github.com/codegangsta/cli" "github.com/go-martini/martini" - // "github.com/martini-contrib/oauth2" - // "github.com/martini-contrib/sessions" "github.com/gogits/binding" @@ -21,6 +19,7 @@ import ( "github.com/gogits/gogs/modules/base" "github.com/gogits/gogs/modules/log" "github.com/gogits/gogs/modules/middleware" + "github.com/gogits/gogs/modules/oauth2" "github.com/gogits/gogs/routers" "github.com/gogits/gogs/routers/admin" "github.com/gogits/gogs/routers/api/v1" @@ -59,19 +58,17 @@ func runWeb(*cli.Context) { // Middlewares. m.Use(middleware.Renderer(middleware.RenderOptions{Funcs: []template.FuncMap{base.TemplateFuncs}})) - - // scope := "https://api.github.com/user" - // oauth2.PathCallback = "/oauth2callback" - // m.Use(sessions.Sessions("my_session", sessions.NewCookieStore([]byte("secret123")))) - // m.Use(oauth2.Github(&oauth2.Options{ - // ClientId: "09383403ff2dc16daaa1", - // ClientSecret: "5f6e7101d30b77952aab22b75eadae17551ea6b5", - // RedirectURL: base.AppUrl + oauth2.PathCallback, - // Scopes: []string{scope}, - // })) - m.Use(middleware.InitContext()) + scope := "https://api.github.com/user" + oauth2.PathCallback = "/oauth2callback" + m.Use(oauth2.Github(&oauth2.Options{ + ClientId: "09383403ff2dc16daaa1", + ClientSecret: "5f6e7101d30b77952aab22b75eadae17551ea6b5", + RedirectURL: base.AppUrl + oauth2.PathCallback, + Scopes: []string{scope}, + })) + reqSignIn := middleware.Toggle(&middleware.ToggleOptions{SignInRequire: true}) ignSignIn := middleware.Toggle(&middleware.ToggleOptions{SignInRequire: base.Service.RequireSignInView}) reqSignOut := middleware.Toggle(&middleware.ToggleOptions{SignOutRequire: true}) |