mirror of
https://github.com/sourcegraph/sourcegraph.git
synced 2026-02-06 18:11:48 +00:00
This is a big one! Merged the enterprise frontend with the OSS one, to get yet another step closer to getting rid of the enterprise directory :)
31 lines
818 B
Go
31 lines
818 B
Go
package githuboauth
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/sourcegraph/sourcegraph/cmd/frontend/auth"
|
|
"github.com/sourcegraph/sourcegraph/cmd/frontend/internal/auth/oauth"
|
|
"github.com/sourcegraph/sourcegraph/internal/database"
|
|
"github.com/sourcegraph/sourcegraph/internal/extsvc"
|
|
"github.com/sourcegraph/sourcegraph/schema"
|
|
)
|
|
|
|
const authPrefix = auth.AuthURLPrefix + "/github"
|
|
|
|
func init() {
|
|
oauth.AddIsOAuth(func(p schema.AuthProviders) bool {
|
|
return p.Github != nil
|
|
})
|
|
}
|
|
|
|
func Middleware(db database.DB) *auth.Middleware {
|
|
return &auth.Middleware{
|
|
API: func(next http.Handler) http.Handler {
|
|
return oauth.NewMiddleware(db, extsvc.TypeGitHub, authPrefix, true, next)
|
|
},
|
|
App: func(next http.Handler) http.Handler {
|
|
return oauth.NewMiddleware(db, extsvc.TypeGitHub, authPrefix, false, next)
|
|
},
|
|
}
|
|
}
|