diff --git a/README.md b/README.md index f6db9cc..0e3cec1 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ The `open` authentication type bypasses authentication checks. To use `basic` authentication, set `ORD_AUTH` to `["basic"]` and provide credentials in `BASIC_AUTH`. Example: -```json +```bash BASIC_AUTH='{"user":"password"}' ``` diff --git a/__tests__/__snapshots__/mockedCsn.test.js.snap b/__tests__/__snapshots__/mockedCsn.test.js.snap index d2f4676..3ddc0ec 100644 --- a/__tests__/__snapshots__/mockedCsn.test.js.snap +++ b/__tests__/__snapshots__/mockedCsn.test.js.snap @@ -29,13 +29,21 @@ exports[`Tests for ORD document generated out of mocked csn files Tests for ORD "releaseStatus": "active", "resourceDefinitions": [ { - "accessStrategies": [], + "accessStrategies": [ + { + "type": "open", + }, + ], "mediaType": "application/json", "type": "openapi-v3", "url": "/ord/v1/customer.capirebookshopordsample:apiResource:AdminService:v1/AdminService.oas3.json", }, { - "accessStrategies": [], + "accessStrategies": [ + { + "type": "open", + }, + ], "mediaType": "application/xml", "type": "edmx", "url": "/ord/v1/customer.capirebookshopordsample:apiResource:AdminService:v1/AdminService.edmx", @@ -73,13 +81,21 @@ exports[`Tests for ORD document generated out of mocked csn files Tests for ORD "releaseStatus": "active", "resourceDefinitions": [ { - "accessStrategies": [], + "accessStrategies": [ + { + "type": "open", + }, + ], "mediaType": "application/json", "type": "openapi-v3", "url": "/ord/v1/customer.capirebookshopordsample:apiResource:CatalogService:v1/CatalogService.oas3.json", }, { - "accessStrategies": [], + "accessStrategies": [ + { + "type": "open", + }, + ], "mediaType": "application/xml", "type": "edmx", "url": "/ord/v1/customer.capirebookshopordsample:apiResource:CatalogService:v1/CatalogService.edmx", @@ -117,13 +133,21 @@ exports[`Tests for ORD document generated out of mocked csn files Tests for ORD "releaseStatus": "active", "resourceDefinitions": [ { - "accessStrategies": [], + "accessStrategies": [ + { + "type": "open", + }, + ], "mediaType": "application/json", "type": "openapi-v3", "url": "/ord/v1/customer.capirebookshopordsample:apiResource:CinemaService:v1/CinemaService.oas3.json", }, { - "accessStrategies": [], + "accessStrategies": [ + { + "type": "open", + }, + ], "mediaType": "application/xml", "type": "edmx", "url": "/ord/v1/customer.capirebookshopordsample:apiResource:CinemaService:v1/CinemaService.edmx", @@ -168,7 +192,11 @@ exports[`Tests for ORD document generated out of mocked csn files Tests for ORD "releaseStatus": "active", "resourceDefinitions": [ { - "accessStrategies": [], + "accessStrategies": [ + { + "type": "open", + }, + ], "mediaType": "application/json", "type": "asyncapi-v2", "url": "/ord/v1/customer.capirebookshopordsample:eventResource:AdminService:v1/AdminService.asyncapi2.json", @@ -193,7 +221,11 @@ exports[`Tests for ORD document generated out of mocked csn files Tests for ORD "releaseStatus": "active", "resourceDefinitions": [ { - "accessStrategies": [], + "accessStrategies": [ + { + "type": "open", + }, + ], "mediaType": "application/json", "type": "asyncapi-v2", "url": "/ord/v1/customer.capirebookshopordsample:eventResource:CatalogService:v1/CatalogService.asyncapi2.json", @@ -218,7 +250,11 @@ exports[`Tests for ORD document generated out of mocked csn files Tests for ORD "releaseStatus": "active", "resourceDefinitions": [ { - "accessStrategies": [], + "accessStrategies": [ + { + "type": "open", + }, + ], "mediaType": "application/json", "type": "asyncapi-v2", "url": "/ord/v1/customer.capirebookshopordsample:eventResource:CinemaService:v1/CinemaService.asyncapi2.json", diff --git a/__tests__/__snapshots__/ord.e2e.test.js.snap b/__tests__/__snapshots__/ord.e2e.test.js.snap index 7eddd18..422a442 100644 --- a/__tests__/__snapshots__/ord.e2e.test.js.snap +++ b/__tests__/__snapshots__/ord.e2e.test.js.snap @@ -28,13 +28,21 @@ exports[`End-to-end test for ORD document Tests for default ORD document when .c "releaseStatus": "active", "resourceDefinitions": [ { - "accessStrategies": [], + "accessStrategies": [ + { + "type": "open", + }, + ], "mediaType": "application/json", "type": "openapi-v3", "url": "/ord/v1/sap.test.cdsrc.sample:apiResource:AdminService:v1/AdminService.oas3.json", }, { - "accessStrategies": [], + "accessStrategies": [ + { + "type": "open", + }, + ], "mediaType": "application/xml", "type": "edmx", "url": "/ord/v1/sap.test.cdsrc.sample:apiResource:AdminService:v1/AdminService.edmx", @@ -105,7 +113,11 @@ exports[`End-to-end test for ORD document Tests for default ORD document when .c "releaseStatus": "active", "resourceDefinitions": [ { - "accessStrategies": [], + "accessStrategies": [ + { + "type": "open", + }, + ], "mediaType": "application/json", "type": "asyncapi-v2", "url": "/ord/v1/sap.test.cdsrc.sample:eventResource:AdminService:v1/AdminService.asyncapi2.json", @@ -231,13 +243,236 @@ exports[`End-to-end test for ORD document Tests for default ORD document when .c "releaseStatus": "active", "resourceDefinitions": [ { - "accessStrategies": [], + "accessStrategies": [ + { + "type": "open", + }, + ], + "mediaType": "application/json", + "type": "openapi-v3", + "url": "/ord/v1/sap.test.cdsrc.sample:apiResource:AdminService:v1/AdminService.oas3.json", + }, + { + "accessStrategies": [ + { + "type": "open", + }, + ], + "mediaType": "application/xml", + "type": "edmx", + "url": "/ord/v1/sap.test.cdsrc.sample:apiResource:AdminService:v1/AdminService.edmx", + }, + ], + "shortDescription": "short description for test AdminService", + "title": "This is test AdminService title", + "version": "2.0.0", + "visibility": "public", + }, + ], + "consumptionBundles": [ + { + "description": "This Consumption Bundle contains all resources of the reference app which are unprotected and do not require authentication", + "lastUpdate": "2024-11-04T14:33:25+01:00", + "ordId": "capirebookshopordsample:consumptionBundle:noAuth:v1", + "shortDescription": "If we have another protected API then it will be another object", + "title": "Unprotected resources", + "version": "1.0.0", + }, + ], + "dataProducts": [ + { + "category": "business-object", + "description": "The Supplier data product offers access to all customers.", + "entityTypes": [ + "sap.odm:entityType:BusinessPartner:v1", + "sap.sm:entityType:BusinessPartner:v1", + ], + "lastUpdate": "2024-06-20T14:04:01+01:00", + "localId": "Supplier", + "ordId": "sap.sm:dataProduct:Supplier:v1", + "outputPorts": [ + { + "ordId": "sap.sm:apiResource:SupplierService:v1", + }, + ], + "partOfPackage": "sap.sm:package:smDataProducts:v1", + "releaseStatus": "active", + "responsible": "sap:ach:CIC-DP-CO", + "shortDescription": "Ariba Supplier data product", + "title": "Supplier", + "type": "primary", + "version": "1.1.11", + "visibility": "public", + }, + ], + "description": "this is my custom description", + "eventResources": [ + { + "description": "CAP Event resource describing events / messages.", + "entityTypeMappings": { + "entityTypeTargets": [ + { + "ordId": "sap.odm:entityType:test-from-extension:v1", + }, + ], + }, + "extensible": { + "supported": "yes", + }, + "lastUpdate": "2024-11-04T14:33:25+01:00", + "ordId": "sap.test.cdsrc.sample:eventResource:AdminService:v1", + "partOfGroups": [ + "sap.cds:service:sap.test.cdsrc.sample:AdminService", + ], + "partOfPackage": "sap.test.cdsrc.sample:package:capirebookshopordsample-event:v1", + "releaseStatus": "active", + "resourceDefinitions": [ + { + "accessStrategies": [ + { + "type": "open", + }, + ], + "mediaType": "application/json", + "type": "asyncapi-v2", + "url": "/ord/v1/sap.test.cdsrc.sample:eventResource:AdminService:v1/AdminService.asyncapi2.json", + }, + ], + "shortDescription": "short description for test AdminService", + "title": "This is test AdminService title", + "version": "2.0.0", + "visibility": "public", + }, + ], + "groups": [ + { + "groupId": "sap.cds:service:sap.test.cdsrc.sample:AdminService", + "groupTypeId": "sap.cds:service", + "title": "This is test AdminService title", + }, + { + "groupId": "sap.cds:service:sap.test.cdsrc.sample:CatalogService", + "groupTypeId": "sap.cds:service", + "title": "This is test Catalog Service title", + }, + { + "groupId": "sap.cds:service:sap.test.cdsrc.sample:CinemaService", + "groupTypeId": "sap.cds:service", + "title": "This is test Cinema Service title", + }, + ], + "openResourceDiscovery": "1.10", + "packages": [ + { + "description": "Description for capire bookshop ord sample", + "ordId": "sap.test.cdsrc.sample:package:capirebookshopordsample-api:v1", + "partOfProducts": [ + "customer:product:capire.bookshop.ord.sample:", + ], + "shortDescription": "Short description of capire bookshop ord sample", + "title": "capire bookshop ord sample", + "vendor": "customer:vendor:Customer:", + "version": "1.0.0", + }, + { + "description": "Description for capire bookshop ord sample", + "ordId": "sap.test.cdsrc.sample:package:capirebookshopordsample-event:v1", + "partOfProducts": [ + "customer:product:capire.bookshop.ord.sample:", + ], + "title": "capire bookshop ord sample", + "vendor": "customer:vendor:Customer:", + "version": "1.0.1", + }, + { + "description": "Description for capire bookshop ord sample", + "ordId": "sap.test.cdsrc.sample:package:capirebookshopordsample-integrationDependency:v1", + "partOfProducts": [ + "customer:product:capire.bookshop.ord.sample:", + ], + "shortDescription": "Short description of capire bookshop ord sample", + "title": "capire bookshop ord sample", + "vendor": "customer:vendor:Customer:", + "version": "1.0.0", + }, + { + "description": "Description for capire bookshop ord sample", + "ordId": "sap.test.cdsrc.sample:package:capirebookshopordsample-entityType:v1", + "partOfProducts": [ + "customer:product:capire.bookshop.ord.sample:", + ], + "shortDescription": "Short description of capire bookshop ord sample", + "title": "capire bookshop ord sample", + "vendor": "customer:vendor:Customer:", + "version": "1.0.0", + }, + { + "description": "Description for capire bookshop ord sample version 2", + "ordId": "sap.test.cdsrc.sample:package:capirebookshopordsample-api:v2", + "partOfProducts": [ + "customer:product:capire.bookshop.ord.sample:", + ], + "shortDescription": "Short description for capire bookshop ord sample version 2", + "title": "capire bookshop ord sample", + "vendor": "customer:vendor:Customer:", + "version": "2.0.0", + }, + ], + "policyLevel": "sap:core:v1", + "products": [ + { + "ordId": "customer:product:capire.bookshop.ord.sample:", + "shortDescription": "Short description of capire bookshop ord sample", + "title": "capire bookshop ord sample", + "vendor": "customer:vendor:customer:", + }, + ], +} +`; + +exports[`End-to-end test for ORD document Tests for default ORD document when .cdsrc.json is present Successfully create ORD Documents with defaults and applicationNamespace configured incorrectly 1`] = ` +{ + "$schema": "https://sap.github.io/open-resource-discovery/spec-v1/interfaces/Document.schema.json", + "apiResources": [ + { + "apiProtocol": "odata-v4", + "description": "Description for AdminService", + "entityTypeMappings": [ + { + "entityTypeTargets": [ + { + "ordId": "sap.odm:entityType:BusinessPartner:v1", + }, + ], + }, + ], + "entryPoints": [ + "/odata/v4/admin", + ], + "extensible": { + "supported": "yes", + }, + "lastUpdate": "2024-11-04T14:33:25+01:00", + "ordId": "sap.test.cdsrc.sample:apiResource:AdminService:v1", + "partOfPackage": "sap.test.cdsrc.sample:package:capirebookshopordsample-api:v1", + "releaseStatus": "active", + "resourceDefinitions": [ + { + "accessStrategies": [ + { + "type": "open", + }, + ], "mediaType": "application/json", "type": "openapi-v3", "url": "/ord/v1/sap.test.cdsrc.sample:apiResource:AdminService:v1/AdminService.oas3.json", }, { - "accessStrategies": [], + "accessStrategies": [ + { + "type": "open", + }, + ], "mediaType": "application/xml", "type": "edmx", "url": "/ord/v1/sap.test.cdsrc.sample:apiResource:AdminService:v1/AdminService.edmx", @@ -308,7 +543,11 @@ exports[`End-to-end test for ORD document Tests for default ORD document when .c "releaseStatus": "active", "resourceDefinitions": [ { - "accessStrategies": [], + "accessStrategies": [ + { + "type": "open", + }, + ], "mediaType": "application/json", "type": "asyncapi-v2", "url": "/ord/v1/sap.test.cdsrc.sample:eventResource:AdminService:v1/AdminService.asyncapi2.json", diff --git a/__tests__/mockedCsn.test.js b/__tests__/mockedCsn.test.js index 066d3b4..73c64b1 100644 --- a/__tests__/mockedCsn.test.js +++ b/__tests__/mockedCsn.test.js @@ -15,6 +15,11 @@ describe("Tests for ORD document generated out of mocked csn files", () => { beforeAll(() => { cds.root = path.join(__dirname, "bookshop"); + jest.spyOn(cds, "context", "get").mockReturnValue({ + authConfig: { + types: ["open"] + } + }); jest.spyOn(require("../lib/date"), "getRFC3339Date").mockReturnValue("2024-11-04T14:33:25+01:00"); ord = require("../lib/ord"); }); diff --git a/__tests__/ord.e2e.test.js b/__tests__/ord.e2e.test.js index 028e9ad..1c8a565 100644 --- a/__tests__/ord.e2e.test.js +++ b/__tests__/ord.e2e.test.js @@ -2,6 +2,22 @@ const cds = require("@sap/cds"); const path = require("path"); describe("End-to-end test for ORD document", () => { + + beforeAll(() => { + process.env.DEBUG = "true"; + jest.spyOn(cds, "context", "get").mockReturnValue({ + authConfig: { + types: ["open"] + } + }); + // Logger.warn = jest.fn(); + }); + + afterAll(() => { + jest.clearAllMocks(); + jest.resetAllMocks(); + }); + describe("Tests for default ORD document when .cdsrc.json is present", () => { let csn, ord; @@ -14,6 +30,7 @@ describe("End-to-end test for ORD document", () => { afterEach(() => { cds.root = path.join(__dirname, "bookshop"); + delete cds.env.export; }); test("Successfully create ORD Documents with defaults", () => { @@ -21,6 +38,16 @@ describe("End-to-end test for ORD document", () => { expect(document).toMatchSnapshot(); }); + test("Successfully create ORD Documents with defaults and applicationNamespace configured incorrectly", () => { + cds.env.export = { + asyncapi: { + applicationNamespace: "non-ord-namespace" + } + }; + const document = ord(csn); + expect(document).toMatchSnapshot(); + }); + test("Exception thrown while package.json not found", () => { cds.root = path.join(__dirname, "folderWithNoPackageJson"); expect(() => ord(csn)).toThrowError("package.json not found in the project root directory"); diff --git a/__tests__/unittest/__snapshots__/defaults.test.js.snap b/__tests__/unittest/__snapshots__/defaults.test.js.snap index eac9f4e..26b4bed 100644 --- a/__tests__/unittest/__snapshots__/defaults.test.js.snap +++ b/__tests__/unittest/__snapshots__/defaults.test.js.snap @@ -7,7 +7,11 @@ exports[`defaults baseTemplate should return default value 1`] = ` "openResourceDiscoveryV1": { "documents": [ { - "accessStrategies": [], + "accessStrategies": [ + { + "type": "open", + }, + ], "url": "/ord/v1/documents/ord-document", }, ], diff --git a/__tests__/unittest/__snapshots__/templates.test.js.snap b/__tests__/unittest/__snapshots__/templates.test.js.snap index 6ca3ed9..cd7d9fe 100644 --- a/__tests__/unittest/__snapshots__/templates.test.js.snap +++ b/__tests__/unittest/__snapshots__/templates.test.js.snap @@ -20,13 +20,21 @@ exports[`templates createAPIResourceTemplate should create API resource template "releaseStatus": "active", "resourceDefinitions": [ { - "accessStrategies": [], + "accessStrategies": [ + { + "type": "open", + }, + ], "mediaType": "application/json", "type": "openapi-v3", "url": "/ord/v1/customer.testNamespace:apiResource:MyService:v1/MyService.oas3.json", }, { - "accessStrategies": [], + "accessStrategies": [ + { + "type": "open", + }, + ], "mediaType": "application/xml", "type": "edmx", "url": "/ord/v1/customer.testNamespace:apiResource:MyService:v1/MyService.edmx", @@ -94,7 +102,11 @@ exports[`templates createEventResourceTemplate should create event resource temp "releaseStatus": "active", "resourceDefinitions": [ { - "accessStrategies": [], + "accessStrategies": [ + { + "type": "open", + }, + ], "mediaType": "application/json", "type": "asyncapi-v2", "url": "/ord/v1/customer.testNamespace:eventResource:MyService:v1/MyService.asyncapi2.json", @@ -124,7 +136,11 @@ exports[`templates createEventResourceTemplate should create event resource temp "releaseStatus": "active", "resourceDefinitions": [ { - "accessStrategies": [], + "accessStrategies": [ + { + "type": "open", + }, + ], "mediaType": "application/json", "type": "asyncapi-v2", "url": "/ord/v1/customer.testNamespace:eventResource:MyService:v1/MyService.asyncapi2.json", @@ -167,13 +183,21 @@ exports[`templates ordExtension should add apiResources with ORD Extension "visi "releaseStatus": "active", "resourceDefinitions": [ { - "accessStrategies": [], + "accessStrategies": [ + { + "type": "open", + }, + ], "mediaType": "application/json", "type": "openapi-v3", "url": "/ord/v1/customer.testNamespace:apiResource:MyService:v1/MyService.oas3.json", }, { - "accessStrategies": [], + "accessStrategies": [ + { + "type": "open", + }, + ], "mediaType": "application/xml", "type": "edmx", "url": "/ord/v1/customer.testNamespace:apiResource:MyService:v1/MyService.edmx", @@ -203,7 +227,11 @@ exports[`templates ordExtension should add events with ORD Extension "visibility "releaseStatus": "active", "resourceDefinitions": [ { - "accessStrategies": [], + "accessStrategies": [ + { + "type": "open", + }, + ], "mediaType": "application/json", "type": "asyncapi-v2", "url": "/ord/v1/customer.testNamespace:eventResource:MyService:v1/MyService.asyncapi2.json", diff --git a/__tests__/unittest/authentication.test.js b/__tests__/unittest/authentication.test.js index f3e07a4..571e365 100644 --- a/__tests__/unittest/authentication.test.js +++ b/__tests__/unittest/authentication.test.js @@ -1,6 +1,6 @@ const cds = require('@sap/cds'); const { AUTHENTICATION_TYPE, CERT_SUBJECT_HEADER_KEY } = require('../../lib/constants'); -const { authenticate, createAuthConfig, getAuthenticationTypes } = require('../../lib/authentication'); +const { authenticate, createAuthConfig } = require('../../lib/authentication'); const { Logger } = require('../../lib/logger'); describe('authentication', () => { @@ -56,12 +56,6 @@ describe('authentication', () => { cds.env.authentication = {}; }); - it('should return array of authentication types from environment variables: Basic auth', () => { - process.env.ORD_AUTH = `["${AUTHENTICATION_TYPE.Basic}"]`; - const authTypes = getAuthenticationTypes(); - expect(authTypes).toEqual([AUTHENTICATION_TYPE.Basic]); - }); - it('should return default configuration when no authentication type is provided', () => { const authConfig = createAuthConfig(); expect(authConfig).toEqual({ types: [AUTHENTICATION_TYPE.Open] }); diff --git a/__tests__/unittest/defaults.test.js b/__tests__/unittest/defaults.test.js index 2da3fd7..ce87ecc 100644 --- a/__tests__/unittest/defaults.test.js +++ b/__tests__/unittest/defaults.test.js @@ -1,3 +1,9 @@ +const cds = require('@sap/cds'); +jest.spyOn(cds, "context", "get").mockReturnValue({ + authConfig: { + types: ["open"] + } +}); const defaults = require('../../lib/defaults'); describe('defaults', () => { diff --git a/__tests__/unittest/templates.test.js b/__tests__/unittest/templates.test.js index 0a84b33..fa1abb6 100644 --- a/__tests__/unittest/templates.test.js +++ b/__tests__/unittest/templates.test.js @@ -1,4 +1,9 @@ const cds = require('@sap/cds'); +jest.spyOn(cds, "context", "get").mockReturnValue({ + authConfig: { + types: ["open"] + } +}); const { createEntityTypeTemplate, createEntityTypeMappingsItemTemplate, diff --git a/lib/authentication.js b/lib/authentication.js index fc14282..77bbc27 100644 --- a/lib/authentication.js +++ b/lib/authentication.js @@ -36,17 +36,10 @@ function createAuthConfig() { } if (authConfig.types.includes(AUTHENTICATION_TYPE.Basic)) { - if (process.env.BASIC_AUTH) { - authConfig.credentials = Object.entries(JSON.parse(process.env.BASIC_AUTH)).map(([username, password]) => - ({ - username, password - }))[0]; - } else { - authConfig.credentials = Object.entries(cds.env.authentication.credentials).map(([username, password]) => - ({ - username, password - }))[0]; - } + const credentials = process.env.BASIC_AUTH ? JSON.parse(process.env.BASIC_AUTH) : cds.env.authentication.credentials; + authConfig.credentials = Object.entries(credentials).map(([username, password]) => ({ + username, password + }))[0]; } return authConfig; @@ -56,18 +49,6 @@ function createAuthConfig() { } } -/** - * Retrieve distinct values for the authentication types from environment variables. - * @returns {Array} Array of authentication types - */ -function getAuthenticationTypes() { - if (process.env.ORD_AUTH) { - return [...new Set(JSON.parse(process.env.ORD_AUTH))]; - } else { - return [...new Set(cds.env.authentication?.type)]; - } -} - /** * Middleware to authenticate the request based on the authentication configuration. */ @@ -111,6 +92,5 @@ async function authenticate(req, res, next) { module.exports = { authenticate, - getAuthenticationTypes, createAuthConfig }; \ No newline at end of file diff --git a/lib/defaults.js b/lib/defaults.js index 50f5403..f688b8f 100644 --- a/lib/defaults.js +++ b/lib/defaults.js @@ -1,10 +1,10 @@ +const cds = require("@sap/cds"); const { AUTH_TYPE_ORD_ACCESS_STRATEGY_MAP, DESCRIPTION_PREFIX, OPEN_RESOURCE_DISCOVERY_VERSION, SHORT_DESCRIPTION_PREFIX, } = require("./constants"); -const { getAuthenticationTypes } = require("./authentication"); const regexWithRemoval = (name) => { return name?.replace(/[^a-zA-Z0-9]/g, ""); @@ -90,7 +90,7 @@ module.exports = { documents: [ { url: "/ord/v1/documents/ord-document", - accessStrategies: getAuthenticationTypes().map((type) => ({ + accessStrategies: cds.context.authConfig.types.map((type) => ({ type: AUTH_TYPE_ORD_ACCESS_STRATEGY_MAP[type], })), }, diff --git a/lib/logger.js b/lib/logger.js index c711473..f887b66 100644 --- a/lib/logger.js +++ b/lib/logger.js @@ -1,9 +1,18 @@ const cds = require("@sap/cds"); +const _debugLevel = cds.env?.DEBUG || process.env.DEBUG; + +function _getLogLevel(debugLevel, logLevels) { + if (debugLevel) { + logLevels.DEBUG + } + return logLevels.WARN; +} + +const logLevel = _getLogLevel(_debugLevel, cds.log?.levels); + const Logger = cds.log("ord-plugin", { - level: cds.env?.DEBUG || process.env.DEBUG - ? cds.log?.levels?.DEBUG - : cds.log?.levels?.WARN, + level: logLevel, }); module.exports = { diff --git a/lib/templates.js b/lib/templates.js index ab3206b..dd120fe 100644 --- a/lib/templates.js +++ b/lib/templates.js @@ -13,7 +13,6 @@ const { SHORT_DESCRIPTION_PREFIX } = require("./constants"); const { AUTH_TYPE_ORD_ACCESS_STRATEGY_MAP } = require("./constants"); -const { getAuthenticationTypes } = require("./authentication"); const { Logger } = require("./logger"); function unflatten(flattedObject) { @@ -149,7 +148,7 @@ function _getResourceDefinition(resourceType, mediaType, ordId, serviceName, fil type: resourceType, mediaType: `application/${mediaType}`, url: `/ord/v1/${ordId}/${serviceName}.${fileExtension}`, - accessStrategies: getAuthenticationTypes().map((type) => ({ + accessStrategies: cds.context.authConfig.types.map((type) => ({ type: AUTH_TYPE_ORD_ACCESS_STRATEGY_MAP[type], })), }