diff options
Diffstat (limited to 'overleaf-mods/overleaf-ldap-oauth2/ldap-overleaf-sl/sharelatex/authcontroller.diff')
-rw-r--r-- | overleaf-mods/overleaf-ldap-oauth2/ldap-overleaf-sl/sharelatex/authcontroller.diff | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/overleaf-mods/overleaf-ldap-oauth2/ldap-overleaf-sl/sharelatex/authcontroller.diff b/overleaf-mods/overleaf-ldap-oauth2/ldap-overleaf-sl/sharelatex/authcontroller.diff new file mode 100644 index 0000000..c45a271 --- /dev/null +++ b/overleaf-mods/overleaf-ldap-oauth2/ldap-overleaf-sl/sharelatex/authcontroller.diff @@ -0,0 +1,103 @@ +23,24d22 +< const axios = require('axios').default +< const Path = require('path') +195c193 +< logger.debug({ email }, 'too many login requests') +--- +> logger.log({ email }, 'too many login requests') +227c225 +< logger.debug({ email }, 'failed log in') +--- +> logger.log({ email }, 'failed log in') +298,364d295 +< oauth2Redirect(req, res, next) { +< res.redirect(`${process.env.OAUTH_AUTH_URL}?` + +< querystring.stringify({ +< client_id: process.env.OAUTH_CLIENT_ID, +< response_type: "code", +< redirect_uri: (process.env.SHARELATEX_SITE_URL + "/oauth/callback"), +< })); +< }, +< +< oauth2Callback(req, res, next) { +< const code = req.query.code; +< +< //construct axios body +< const params = new URLSearchParams() +< params.append('grant_type', "authorization_code") +< params.append('client_id', process.env.OAUTH_CLIENT_ID) +< params.append('client_secret', process.env.OAUTH_CLIENT_SECRET) +< params.append("code", code) +< params.append('redirect_uri', (process.env.SHARELATEX_SITE_URL + "/oauth/callback")) +< +< +< // json_body = { +< // "grant_type": "authorization_code", +< // client_id: process.env.OAUTH_CLIENT_ID, +< // client_secret: process.env.OAUTH_CLIENT_SECRET, +< // "code": code, +< // redirect_uri: (process.env.SHARELATEX_SITE_URL + "/oauth/callback"), +< // } +< +< axios.post(process.env.OAUTH_ACCESS_URL, params, { +< headers: { +< "Content-Type": "application/x-www-form-urlencoded", +< +< } +< }).then(access_res => { +< +< // console.log("respond is " + JSON.stringify(access_res.data)) +< // console.log("authorization_bearer_is " + authorization_bearer) +< authorization_bearer = "Bearer " + access_res.data.access_token +< +< let axios_get_config = { +< headers: { +< "Content-Type": "application/x-www-form-urlencoded", +< "Authorization": authorization_bearer, +< }, +< params: access_res.data +< } +< +< axios.get(process.env.OAUTH_USER_URL, axios_get_config).then(info_res => { +< // console.log("oauth_user: ", JSON.stringify(info_res.data)); +< if (info_res.data.err) { +< res.json({message: info_res.data.err}); +< } else { +< AuthenticationManager.createUserIfNotExist(info_res.data, (error, user) => { +< if (error) { +< res.json({message: error}); +< } else { +< // console.log("real_user: ", user); +< AuthenticationController.finishLogin(user, req, res, next); +< } +< }); +< } +< }); +< }); +< }, +< +< +444c375 +< logger.debug( +--- +> logger.log( +477c408 +< email, +--- +> email: email, +547c478 +< logger.debug( +--- +> logger.log( +558c489 +< logger.debug( +--- +> logger.log( +568c499 +< logger.debug( +--- +> logger.log( +689c620 +< logger.debug( +--- +> logger.log( |