Skip to content
This repository has been archived by the owner on Jan 17, 2025. It is now read-only.

Commit

Permalink
added auth for DEMO mode, because it is smart for security
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgtho committed Sep 7, 2022
1 parent 633c44a commit c43e100
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions lib/with-token-auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ const HTTPError = require('./http-error')
module.exports = async (context, request, next) => {
logConfig({ azure: { context } })

if (DEMO) {
request.token = { upn: DEMO_USER, DEMO }
return next(context, request)
}

const bearerToken = request.headers.authorization
if (!bearerToken) {
logger('warn', ['with-token-auth', request.url, 'no-authorization-header'])
Expand All @@ -22,6 +17,10 @@ module.exports = async (context, request, next) => {
const validatedToken = await verify(token, TOKEN_AUTH)
request.token = validatedToken

if (DEMO) {
request.token = { upn: DEMO_USER, DEMO }
}

return next(context, request)
} catch (error) {
logger('warn', ['with-token-auth', request.url, 'invalid-token', error])
Expand Down

0 comments on commit c43e100

Please # to comment.