aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/auth.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/auth.ts')
-rw-r--r--server/lib/auth.ts7
1 files changed, 4 insertions, 3 deletions
diff --git a/server/lib/auth.ts b/server/lib/auth.ts
index acf0da18a..466c9bdd4 100644
--- a/server/lib/auth.ts
+++ b/server/lib/auth.ts
@@ -13,6 +13,7 @@ import {
13} from '@server/types/plugins/register-server-auth.model' 13} from '@server/types/plugins/register-server-auth.model'
14import * as express from 'express' 14import * as express from 'express'
15import * as OAuthServer from 'express-oauth-server' 15import * as OAuthServer from 'express-oauth-server'
16import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes'
16 17
17const oAuthServer = new OAuthServer({ 18const oAuthServer = new OAuthServer({
18 useErrorHandler: true, 19 useErrorHandler: true,
@@ -215,7 +216,7 @@ function proxifyExternalAuthBypass (req: express.Request, res: express.Response)
215 const obj = authBypassTokens.get(req.body.externalAuthToken) 216 const obj = authBypassTokens.get(req.body.externalAuthToken)
216 if (!obj) { 217 if (!obj) {
217 logger.error('Cannot authenticate user with unknown bypass token') 218 logger.error('Cannot authenticate user with unknown bypass token')
218 return res.sendStatus(400) 219 return res.sendStatus(HttpStatusCode.BAD_REQUEST_400)
219 } 220 }
220 221
221 const { expires, user, authName, npmName } = obj 222 const { expires, user, authName, npmName } = obj
@@ -223,12 +224,12 @@ function proxifyExternalAuthBypass (req: express.Request, res: express.Response)
223 const now = new Date() 224 const now = new Date()
224 if (now.getTime() > expires.getTime()) { 225 if (now.getTime() > expires.getTime()) {
225 logger.error('Cannot authenticate user with an expired external auth token') 226 logger.error('Cannot authenticate user with an expired external auth token')
226 return res.sendStatus(400) 227 return res.sendStatus(HttpStatusCode.BAD_REQUEST_400)
227 } 228 }
228 229
229 if (user.username !== req.body.username) { 230 if (user.username !== req.body.username) {
230 logger.error('Cannot authenticate user %s with invalid username %s.', req.body.username) 231 logger.error('Cannot authenticate user %s with invalid username %s.', req.body.username)
231 return res.sendStatus(400) 232 return res.sendStatus(HttpStatusCode.BAD_REQUEST_400)
232 } 233 }
233 234
234 // Bypass oauth library validation 235 // Bypass oauth library validation