Skip to content

Commit c3d593f

Browse files
Merge pull request #69 from parameter1/block-non-mindful-apps
Block non-Mindful apps
2 parents 47daa60 + 10aa200 commit c3d593f

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

services/graphql/src/graphql/context/application.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { UserInputError } = require('apollo-server-express');
1+
const { ForbiddenError, UserInputError } = require('apollo-server-express');
22
const { get } = require('object-path');
33
const { applicationService, organizationService } = require('@identity-x/service-clients');
44
const { DISABLED_MINDFUL_TENANT_KEYS } = require('../../env');
@@ -27,7 +27,7 @@ const appIdsToMindfulKeys = new Map([
2727
['5f77a1ac0f883d18cbe63efe', 'fusable'],
2828
['5f77a1b98eebeee1c3ee53fd', 'fusable'],
2929
['5f77a1c80f883d979ae63eff', 'fusable'],
30-
['5f77a1e10f883d280fe63f00', 'randall-reilly'],
30+
['5f77a1fd0f883d221fe63f01', 'fusable'],
3131
['650465135269f6714f6bcdf9', 'fusable'],
3232
['5e28a3dd58e67b229e55ae43', 'im'],
3333
['5e28a2c558e67b89b255ae3a', 'ironmarkets'],
@@ -47,6 +47,7 @@ const appIdsToMindfulKeys = new Map([
4747
['5e28a4c858e67b86c955ae4d', 'pmmi'],
4848
['649063f19a64332c8ec42eed', 'pmmi'],
4949
['6499da19f70f36fef3aa008c', 'pmmi'],
50+
['5f77a1e10f883d280fe63f00', 'randall-reilly'],
5051
['6176f26a1fa8d14997cc99f5', 'rmm'],
5152
['629bac8439347cfce3861789', 'smg'],
5253
['62a20ab439347c3abb862984', 'smg'],
@@ -57,7 +58,7 @@ const appIdsToMindfulKeys = new Map([
5758

5859
const { log } = console;
5960

60-
let nonMindfulAppIdRequests = 0;
61+
const blockedAppIdRequests = new Map();
6162

6263
class AppContext {
6364
constructor(id) {
@@ -66,6 +67,12 @@ class AppContext {
6667
if (this.key && disabledMinfulKeys.has(this.key)) {
6768
throw new Error(`The IdentityX application ID "${id}" is disabled and must migrated to use the new Mindful API. Please contact support for more information.`);
6869
}
70+
if (id && !this.key) {
71+
const n = blockedAppIdRequests.get(id);
72+
blockedAppIdRequests.set(id, (n || 0) + 1);
73+
log(blockedAppIdRequests);
74+
throw new ForbiddenError(`The application ID "${id}" is no longer allowed.`);
75+
}
6976

7077
this.app = {};
7178
this.org = {};
@@ -110,11 +117,6 @@ class AppContext {
110117
check() {
111118
if (this.errored()) throw this.error;
112119
if (!this.exists()) throw new UserInputError('Unable to find an application for this request.');
113-
if (!this.key) {
114-
// log number of non-mindful appId requests since this container was started
115-
nonMindfulAppIdRequests += 1;
116-
log({ nonMindfulAppIdRequests });
117-
}
118120
return true;
119121
}
120122
}

0 commit comments

Comments
 (0)