From 0e284edbad3f6c7eb6ef37f07221fcf36b94b8dc Mon Sep 17 00:00:00 2001 From: Aileen Nowak Date: Tue, 9 Aug 2022 11:09:13 +0100 Subject: [PATCH] Allowed core integrations to work with Admin API --- ghost/core/core/server/data/schema/fixtures/fixtures.json | 2 +- ghost/core/core/server/data/schema/schema.js | 2 +- ghost/core/core/server/services/auth/api-key/admin.js | 6 +----- ghost/core/core/server/services/auth/api-key/content.js | 6 +----- ghost/core/test/unit/server/data/schema/integrity.test.js | 2 +- ghost/core/test/utils/fixtures/fixtures.json | 2 +- 6 files changed, 6 insertions(+), 14 deletions(-) diff --git a/ghost/core/core/server/data/schema/fixtures/fixtures.json b/ghost/core/core/server/data/schema/fixtures/fixtures.json index 94383d3b89..31193c2eee 100644 --- a/ghost/core/core/server/data/schema/fixtures/fixtures.json +++ b/ghost/core/core/server/data/schema/fixtures/fixtures.json @@ -672,7 +672,7 @@ "slug": "ghost-explore", "name": "Ghost Explore", "description": "Built-in Ghost Explore integration", - "type": "builtin", + "type": "core", "api_keys": [{"type": "admin", "role": "Ghost Explore Integration"}] }, { diff --git a/ghost/core/core/server/data/schema/schema.js b/ghost/core/core/server/data/schema/schema.js index 1c7a3d91e5..c40c1edc4d 100644 --- a/ghost/core/core/server/data/schema/schema.js +++ b/ghost/core/core/server/data/schema/schema.js @@ -319,7 +319,7 @@ module.exports = { maxlength: 50, nullable: false, defaultTo: 'custom', - validations: {isIn: [['internal', 'builtin', 'custom']]} + validations: {isIn: [['internal', 'builtin', 'custom', 'core']]} }, name: {type: 'string', maxlength: 191, nullable: false}, slug: {type: 'string', maxlength: 191, nullable: false, unique: true}, diff --git a/ghost/core/core/server/services/auth/api-key/admin.js b/ghost/core/core/server/services/auth/api-key/admin.js index 16a6ffa3bf..6ed73946d8 100644 --- a/ghost/core/core/server/services/auth/api-key/admin.js +++ b/ghost/core/core/server/services/auth/api-key/admin.js @@ -127,11 +127,7 @@ const authenticateWithToken = async (req, res, next, {token, JWT_OPTIONS}) => { // CASE: blocking all non-internal: "custom" and "builtin" integration requests when the limit is reached if (limitService.isLimited('customIntegrations') - && (apiKey.relations.integration - && !['internal'].includes(apiKey.relations.integration.get('type')) - && !['ghost-explore'].includes(apiKey.relations.integration.get('slug')) - ) - ) { + && (apiKey.relations.integration && !['internal', 'core'].includes(apiKey.relations.integration.get('type')))) { // NOTE: using "checkWouldGoOverLimit" instead of "checkIsOverLimit" here because flag limits don't have // a concept of measuring if the limit has been surpassed await limitService.errorIfWouldGoOverLimit('customIntegrations'); diff --git a/ghost/core/core/server/services/auth/api-key/content.js b/ghost/core/core/server/services/auth/api-key/content.js index c6a3a6f6eb..7fcf3f480c 100644 --- a/ghost/core/core/server/services/auth/api-key/content.js +++ b/ghost/core/core/server/services/auth/api-key/content.js @@ -43,11 +43,7 @@ const authenticateContentApiKey = async function authenticateContentApiKey(req, // CASE: blocking all non-internal: "custom" and "builtin" integration requests when the limit is reached if (limitService.isLimited('customIntegrations') - && (apiKey.relations.integration - && !['internal'].includes(apiKey.relations.integration.get('type')) - && !['ghost-explore'].includes(apiKey.relations.integration.get('slug')) - ) - ) { + && (apiKey.relations.integration && !['internal', 'core'].includes(apiKey.relations.integration.get('type')))) { // NOTE: using "checkWouldGoOverLimit" instead of "checkIsOverLimit" here because flag limits don't have // a concept of measuring if the limit has been surpassed await limitService.errorIfWouldGoOverLimit('customIntegrations'); diff --git a/ghost/core/test/unit/server/data/schema/integrity.test.js b/ghost/core/test/unit/server/data/schema/integrity.test.js index a5a3847994..ca371659a7 100644 --- a/ghost/core/test/unit/server/data/schema/integrity.test.js +++ b/ghost/core/test/unit/server/data/schema/integrity.test.js @@ -36,7 +36,7 @@ const validateRouteSettings = require('../../../../../core/server/services/route describe('DB version integrity', function () { // Only these variables should need updating const currentSchemaHash = '45337ae85129a98e4c1b551cc91790da'; - const currentFixturesHash = 'a75211a41f515202280be7cb287e101f'; + const currentFixturesHash = '0ae1887dd0b42508be946bdbd20d41c8'; const currentSettingsHash = 'd54210758b7054e2174fd34aa2320ad7'; const currentRoutesHash = '3d180d52c663d173a6be791ef411ed01'; diff --git a/ghost/core/test/utils/fixtures/fixtures.json b/ghost/core/test/utils/fixtures/fixtures.json index 20a1d7967e..dba988d1a3 100644 --- a/ghost/core/test/utils/fixtures/fixtures.json +++ b/ghost/core/test/utils/fixtures/fixtures.json @@ -845,7 +845,7 @@ "slug": "ghost-explore", "name": "Ghost Explore", "description": "Built-in Ghost Explore integration", - "type": "builtin", + "type": "core", "api_keys": [{"type": "admin", "role": "Ghost Explore Integration"}] }, {