Skip to content

Commit

Permalink
fix(remote-server): api-key-auth (#772)
Browse files Browse the repository at this point in the history
fixes #771
  • Loading branch information
simonas-notcat authored and mirceanis committed Jan 13, 2022
1 parent 84a0377 commit 6d1916b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/remote-server/src/api-key-auth.ts
@@ -1,7 +1,10 @@
import passport from 'passport'
import Bearer from 'passport-http-bearer'
import { Router } from 'express'

export function apiKeyAuth({ apiKey }: { apiKey: string }) {
const router = Router()
router.use(passport.initialize())
passport.use(
new Bearer.Strategy((token, done) => {
if (!apiKey || apiKey === token) {
Expand All @@ -11,5 +14,6 @@ export function apiKeyAuth({ apiKey }: { apiKey: string }) {
}
}),
)
return passport.authenticate('bearer', { session: false })
router.use(passport.authenticate('bearer', { session: false }))
return router
}

0 comments on commit 6d1916b

Please sign in to comment.