mirror of
https://github.com/trufflesecurity/xsshunter
synced 2024-11-27 23:00:18 +00:00
don't reuse oauth client (#32)
This commit is contained in:
parent
7cbd6b7cac
commit
2bb3556c1c
1 changed files with 2 additions and 1 deletions
3
api.js
3
api.js
|
@ -25,7 +25,6 @@ const {OAuth2Client} = require('google-auth-library');
|
|||
|
||||
|
||||
const SCREENSHOTS_DIR = path.resolve(process.env.SCREENSHOTS_DIR);
|
||||
const client = new OAuth2Client(process.env.CLIENT_ID, process.env.CLIENT_SECRET, process.env.NODE_ENV == 'production' ? `https://${process.env.HOSTNAME}/oauth-login` : `http://${process.env.HOSTNAME}/oauth-login`);
|
||||
const SCREENSHOT_FILENAME_REGEX = new RegExp(/^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}\.png$/i);
|
||||
|
||||
|
||||
|
@ -171,6 +170,7 @@ async function set_up_api_server(app) {
|
|||
});
|
||||
|
||||
app.get('/login', (req, res) => {
|
||||
const client = new OAuth2Client(process.env.CLIENT_ID, process.env.CLIENT_SECRET, process.env.NODE_ENV == 'production' ? `https://${process.env.HOSTNAME}/oauth-login` : `http://${process.env.HOSTNAME}/oauth-login`);
|
||||
const authUrl = client.generateAuthUrl({
|
||||
redirect_uri: process.env.NODE_ENV == 'production' ? `https://${process.env.HOSTNAME}/oauth-login` : `http://${process.env.HOSTNAME}/oauth-login`,
|
||||
access_type: 'offline',
|
||||
|
@ -181,6 +181,7 @@ async function set_up_api_server(app) {
|
|||
});
|
||||
|
||||
app.get('/oauth-login', async (req, res) => {
|
||||
const client = new OAuth2Client(process.env.CLIENT_ID, process.env.CLIENT_SECRET, process.env.NODE_ENV == 'production' ? `https://${process.env.HOSTNAME}/oauth-login` : `http://${process.env.HOSTNAME}/oauth-login`);
|
||||
try{
|
||||
const code = req.query.code;
|
||||
const {tokens} = await client.getToken(code);
|
||||
|
|
Loading…
Reference in a new issue