Skip to content

Commit

Permalink
🔐 security: Only make dev endpoints available during tests.
Browse files Browse the repository at this point in the history
Also, make sure that authentication by-pass only works during tests.
  • Loading branch information
make-github-pseudonymous-again committed Sep 20, 2023
1 parent 3ee174b commit 8038c6a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
9 changes: 8 additions & 1 deletion imports/api/authorized.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import isTest from '../app/isTest';

import {
type Authentication,
AuthenticationDangerousNone,
Expand All @@ -14,10 +16,15 @@ const authorized = (
return typeof invocation.userId === 'string' && invocation.userId !== '';
}

// @ts-expect-error We allow a fallthrough here so that this gets pruned in
// production build.
case AuthenticationDangerousNone: {
return true;
if (isTest()) {
return true;
}
}

// eslint-disable-next-line no-fallthrough
default: {
return false;
}
Expand Down
3 changes: 0 additions & 3 deletions imports/api/endpoint/_register/available.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// eslint-disable-next-line import/no-unassigned-import
import '../_dev/reset';

// eslint-disable-next-line import/no-unassigned-import
import '../allergies/changeColor';

Expand Down

0 comments on commit 8038c6a

Please sign in to comment.