From 7fed637506043e4432cbebe041ada0625171cceb Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 22 Apr 2020 16:07:04 +0200 Subject: Begin auth plugin support --- server/middlewares/oauth.ts | 29 ++--------------------------- 1 file changed, 2 insertions(+), 27 deletions(-) (limited to 'server/middlewares/oauth.ts') diff --git a/server/middlewares/oauth.ts b/server/middlewares/oauth.ts index 9eef03bb4..4ae7f18c2 100644 --- a/server/middlewares/oauth.ts +++ b/server/middlewares/oauth.ts @@ -1,17 +1,8 @@ import * as express from 'express' -import * as OAuthServer from 'express-oauth-server' -import { OAUTH_LIFETIME } from '../initializers/constants' import { logger } from '../helpers/logger' import { Socket } from 'socket.io' import { getAccessToken } from '../lib/oauth-model' - -const oAuthServer = new OAuthServer({ - useErrorHandler: true, - accessTokenLifetime: OAUTH_LIFETIME.ACCESS_TOKEN, - refreshTokenLifetime: OAUTH_LIFETIME.REFRESH_TOKEN, - continueMiddleware: true, - model: require('../lib/oauth-model') -}) +import { handleIdAndPassLogin, oAuthServer } from '@server/lib/auth' function authenticate (req: express.Request, res: express.Response, next: express.NextFunction, authenticateInQuery = false) { const options = authenticateInQuery ? { allowBearerTokensInQueryString: true } : {} @@ -73,27 +64,11 @@ function optionalAuthenticate (req: express.Request, res: express.Response, next return next() } -function token (req: express.Request, res: express.Response, next: express.NextFunction) { - return oAuthServer.token()(req, res, err => { - if (err) { - return res.status(err.status) - .json({ - error: err.message, - code: err.name - }) - .end() - } - - return next() - }) -} - // --------------------------------------------------------------------------- export { authenticate, authenticateSocket, authenticatePromiseIfNeeded, - optionalAuthenticate, - token + optionalAuthenticate } -- cgit v1.2.3