companion: remove deprecated "authorized" endpoint

This commit is contained in:
Ifedapo Olarewaju 2019-05-13 19:04:40 +01:00
parent 926b3ee4fa
commit 33add61b61
6 changed files with 3 additions and 47 deletions

View file

@ -106,6 +106,7 @@ PRs are welcome! Please do open an issue to discuss first if it's a big feature,
- [ ] QA: add one integration test (or add to existing test) that uses more exotic (tus) options such as `useFastRemoteRetry` or `removeFingerprintOnSuccess` https://github.com/transloadit/uppy/issues/1327 (@arturi, @ifedapoolarewaju)
- [x] @uppy/companion: investigate 423 and 500 issues with React Native + Url plugin when pause/resuming an upload
- [x] dashboard: Bring back "Drop Here" screen for dragged URLs without introducing flickering (tricky! see PR #1400)
- [x] companion: remove deprecated "authorized" endpoint
## 1.0 Goals

View file

@ -1,30 +0,0 @@
// TODO: this function seems uneccessary. Might be better to just
// have this as a middleware that is used for all auth required routes.
const logger = require('../logger')
/**
* checks if companion is authorized to access a user's provider account.
*
* @param {object} req
* @param {object} res
*/
function authorized (req, res) {
const { params, uppy } = req
const providerName = params.providerName
if (!uppy.providerTokens || !uppy.providerTokens[providerName]) {
return res.json({ authenticated: false })
}
const token = uppy.providerTokens[providerName]
uppy.provider.list({ token, uppy }, (err, response, body) => {
const notAuthenticated = Boolean(err)
if (notAuthenticated) {
logger.debug(`${providerName} failed authorizarion test err:${err}`, 'provider.auth.check')
}
return res.json({ authenticated: !notAuthenticated })
})
}
module.exports = authorized

View file

@ -1,5 +1,4 @@
module.exports = {
authorized: require('./authorized'),
callback: require('./callback'),
sendToken: require('./send-token'),
get: require('./get'),

View file

@ -86,7 +86,6 @@ module.exports.app = (options = {}) => {
app.get('/:providerName/connect', middlewares.hasSessionAndProvider, controllers.connect)
app.get('/:providerName/redirect', middlewares.hasSessionAndProvider, controllers.redirect)
app.get('/:providerName/logout', middlewares.hasSessionAndProvider, middlewares.gentleVerifyToken, controllers.logout)
app.get('/:providerName/authorized', middlewares.hasSessionAndProvider, middlewares.gentleVerifyToken, controllers.authorized)
app.get('/:providerName/send-token', middlewares.hasSessionAndProvider, middlewares.verifyToken, controllers.sendToken)
app.get('/:providerName/list/:id?', middlewares.hasSessionAndProvider, middlewares.verifyToken, controllers.list)
app.post('/:providerName/get/:id', middlewares.hasSessionAndProvider, middlewares.verifyToken, controllers.get)

View file

@ -14,7 +14,7 @@ jest.mock('../../src/server/helpers/oauth-state', () => {
const request = require('supertest')
const tokenService = require('../../src/server/helpers/jwt')
const { authServer, noAuthServer } = require('../mockserver')
const { authServer } = require('../mockserver')
const authData = {
dropbox: 'token value',
drive: 'token value'
@ -99,19 +99,6 @@ describe('test authentication', () => {
})
})
test('check for authenticated provider', () => {
request(authServer)
.get('/drive/authorized/')
.set('uppy-auth-token', token)
.expect(200)
.then((res) => expect(res.body.authenticated).toBe(true))
request(noAuthServer)
.get('/drive/authorized/')
.expect(200)
.then((res) => expect(res.body.authenticated).toBe(false))
})
test('logout provider', () => {
return request(authServer)
.get('/drive/logout/')

View file

@ -13,4 +13,4 @@ authServer.all('/drive/send-token', (req, res, next) => {
authServer.use(app)
module.exports = { authServer, noAuthServer: app }
module.exports = { authServer }