Skip to content

Commit

Permalink
Use new auth domain
Browse files Browse the repository at this point in the history
  • Loading branch information
rhld16 authored May 27, 2023
1 parent fa878c9 commit c6669e5
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"associatedApplications": [
{
"applicationId": "52e1b74e-7f53-41a7-aa0a-a9e9497726f8"
}
]
}
16 changes: 9 additions & 7 deletions Authenticator/routes/pin.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
const { db } = require('../app.js');
const alphabet = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';

var express = require('express');
var router = express.Router();
const express = require('express');
const router = express.Router();

var interval = 5;
const AUTH_URL = "https://auth.drivebackupv2.com";

const interval = 5;

router.post('/', async function (req, res) {
var user_code = nanoid(3) + '-' + nanoid(3);
Expand All @@ -14,13 +16,13 @@ router.post('/', async function (req, res) {

switch (req.body.type) {
case ('googledrive'):
verifyURL = `https://accounts.google.com/o/oauth2/v2/auth?scope=https://www.googleapis.com/auth/drive&access_type=offline&prompt=consent&response_type=code&state=${user_code}&redirect_uri=https://drivebackup.web.app/callback&client_id=602937851350-q69l9u3njis7nhb15cb7qmddqtrmhrg7.apps.googleusercontent.com`;
verifyURL = `https://accounts.google.com/o/oauth2/v2/auth?scope=https://www.googleapis.com/auth/drive&access_type=offline&prompt=consent&response_type=code&state=${user_code}&redirect_uri=${AUTH_URL}/callback&client_id=602937851350-q69l9u3njis7nhb15cb7qmddqtrmhrg7.apps.googleusercontent.com`;
break;
case ('dropbox'):
verifyURL = `https://www.dropbox.com/oauth2/authorize?token_access_type=offline&response_type=code&client_id=9as745vm8v7g0rr&redirect_uri=https://drivebackup.web.app/callback&state=${user_code}`;
verifyURL = `https://www.dropbox.com/oauth2/authorize?token_access_type=offline&response_type=code&client_id=9as745vm8v7g0rr&redirect_uri=${AUTH_URL}/callback&state=${user_code}`;
break;
case ('onedrive'):
verifyURL = `https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id=52e1b74e-7f53-41a7-aa0a-a9e9497726f8&scope=files.readwrite%20offline_access&response_type=code&redirect_uri=https://drivebackup.web.app/callback&state=${user_code}`;
verifyURL = `https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id=52e1b74e-7f53-41a7-aa0a-a9e9497726f8&scope=files.readwrite%20offline_access&response_type=code&redirect_uri=${AUTH_URL}/callback&state=${user_code}`;
break;
default:
return res.send({
Expand All @@ -33,7 +35,7 @@ router.post('/', async function (req, res) {
success: true,
user_code,
device_code,
verification_uri: "https://drivebackup.web.app/",
verification_uri: `${AUTH_URL}/`,
interval
});

Expand Down
8 changes: 5 additions & 3 deletions Authenticator/routes/token.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ const express = require('express');
const fetch = (...args) => import('node-fetch').then(({default: fetch}) => fetch(...args));
let router = express.Router();

const AUTH_URL = "https://auth.drivebackupv2.com";

router.post('/', async function (req, res) {
if (req.body.device_code === undefined || req.body.user_code === undefined) return res.send({
success: false,
Expand Down Expand Up @@ -32,7 +34,7 @@ router.post('/', async function (req, res) {
client_secret: process.env.GOOGLE_SECRET,
code: doc.auth_code,
grant_type: 'authorization_code',
redirect_uri: 'https://drivebackup.web.app/callback'
redirect_uri: `${AUTH_URL}/callback`
})
})
.then(res => res.json())
Expand All @@ -57,7 +59,7 @@ router.post('/', async function (req, res) {
'client_secret': process.env.DROPBOX_SECRET,
'code': doc.auth_code,
'grant_type': 'authorization_code',
'redirect_uri': 'https://drivebackup.web.app/callback'
'redirect_uri': `${AUTH_URL}/callback`
})
})
.then(res => res.json())
Expand All @@ -82,7 +84,7 @@ router.post('/', async function (req, res) {
'client_secret': process.env.ONEDRIVE_SECRET,
'code': doc.auth_code,
'grant_type': 'authorization_code',
'redirect_uri': 'https://drivebackup.web.app/callback'
'redirect_uri': `${AUTH_URL}/callback`
})
})
.then(res => res.json())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ public class Authenticator {
/**
* Endpoints
*/
private static String REQUEST_CODE_ENDPOINT = "https://drivebackup.web.app/pin";
private static String POLL_VERIFICATION_ENDPOINT = "https://drivebackup.web.app/token";
private static String AUTH_URL = "https://auth.drivebackupv2.com";
private static String REQUEST_CODE_ENDPOINT = AUTH_URL + "/pin";
private static String POLL_VERIFICATION_ENDPOINT = AUTH_URL + "/token";
private static String ONEDRIVE_REQUEST_CODE_ENDPOINT = "https://login.microsoftonline.com/common/oauth2/v2.0/devicecode";
private static String ONEDRIVE_POLL_VERIFICATION_ENDPOINT = "https://login.microsoftonline.com/common/oauth2/v2.0/token";

Expand Down Expand Up @@ -191,7 +192,7 @@ public void log(String input, String... placeholders) {
}

} catch (Exception exception) {
NetUtil.catchException(exception, "drivebackup.web.app", logger);
NetUtil.catchException(exception, AUTH_URL, logger);

logger.log(intl("link-provider-failed"), "provider", provider.getName());
MessageUtil.sendConsoleException(exception);
Expand All @@ -201,7 +202,7 @@ public void log(String input, String... placeholders) {
}
}, responseCheckDelay, responseCheckDelay);
} catch (Exception exception) {
NetUtil.catchException(exception, "drivebackup.web.app", logger);
NetUtil.catchException(exception, AUTH_URL, logger);

logger.log(intl("link-provider-failed"), "provider", provider.getName());
MessageUtil.sendConsoleException(exception);
Expand Down

0 comments on commit c6669e5

Please sign in to comment.