|
@@ -25,7 +25,6 @@ sessionStore = new RedisStore(client:sessionsRedisClient)
|
|
|
|
|
|
|
|
passport = require('passport')
|
|
passport = require('passport')
|
|
|
LocalStrategy = require('passport-local').Strategy
|
|
LocalStrategy = require('passport-local').Strategy
|
|
|
-OAuth2Strategy = require('passport-oauth2').Strategy
|
|
|
|
|
|
|
|
|
|
Mongoose = require("./Mongoose")
|
|
Mongoose = require("./Mongoose")
|
|
|
|
|
|
|
@@ -39,7 +38,6 @@ Modules = require "./Modules"
|
|
|
ErrorController = require "../Features/Errors/ErrorController"
|
|
ErrorController = require "../Features/Errors/ErrorController"
|
|
|
UserSessionsManager = require "../Features/User/UserSessionsManager"
|
|
UserSessionsManager = require "../Features/User/UserSessionsManager"
|
|
|
AuthenticationController = require "../Features/Authentication/AuthenticationController"
|
|
AuthenticationController = require "../Features/Authentication/AuthenticationController"
|
|
|
-OverleafAuthenticationController = require "../Features/Authentication/OverleafAuthenticationController"
|
|
|
|
|
|
|
|
|
|
metrics.event_loop?.monitor(logger)
|
|
metrics.event_loop?.monitor(logger)
|
|
|
|
|
|
|
@@ -106,29 +104,6 @@ passport.use(new LocalStrategy(
|
|
|
passport.serializeUser(AuthenticationController.serializeUser)
|
|
passport.serializeUser(AuthenticationController.serializeUser)
|
|
|
passport.deserializeUser(AuthenticationController.deserializeUser)
|
|
passport.deserializeUser(AuthenticationController.deserializeUser)
|
|
|
|
|
|
|
|
-overleafOAuth2Strategy = new OAuth2Strategy(
|
|
|
|
|
- {
|
|
|
|
|
- authorizationURL: 'http://localhost:5000/oauth/authorize',
|
|
|
|
|
- tokenURL: 'http://localhost:5000/oauth/token',
|
|
|
|
|
- clientID: "0479498de20727971b5f40f86dc558264fe7a5021ae74c3e0e03f7dccfeaf0ab",
|
|
|
|
|
- clientSecret: "ecb446d53bb9a1555fecd74b5e3faabefe1345ca6a9228da0c1fbdac2338c502",
|
|
|
|
|
- callbackURL: "http://www.sharelatex.dev:3000/overleaf/callback"
|
|
|
|
|
- },
|
|
|
|
|
- OverleafAuthenticationController.doPassportLogin
|
|
|
|
|
-)
|
|
|
|
|
-overleafOAuth2Strategy.userProfile = (accessToken, cb) ->
|
|
|
|
|
- require("request").get {
|
|
|
|
|
- url: "http://localhost:5000/api/v1/sharelatex/profile"
|
|
|
|
|
- json: true
|
|
|
|
|
- headers:
|
|
|
|
|
- Authorization: "Bearer #{accessToken}"
|
|
|
|
|
- }, (err, response, body) ->
|
|
|
|
|
- console.log {err, response, body}
|
|
|
|
|
- return cb(err) if err?
|
|
|
|
|
- cb(null, body)
|
|
|
|
|
-passport.use(overleafOAuth2Strategy)
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
Modules.hooks.fire 'passportSetup', passport, (err) ->
|
|
Modules.hooks.fire 'passportSetup', passport, (err) ->
|
|
|
if err?
|
|
if err?
|
|
|
logger.err {err}, "error setting up passport in modules"
|
|
logger.err {err}, "error setting up passport in modules"
|