@sap/approuter
Advanced tools
Comparing version 16.5.0 to 16.5.1
@@ -9,2 +9,10 @@ # Change Log | ||
## 16.5.1 - 2024-06-02 | ||
### Fixed | ||
- Enable modify partition configuration in extension | ||
- Adding header to disable html5 repo credentials consumption | ||
- Fixed MIGRATED_DEST flag handling | ||
- Multiple mtas support in SaaS Approuter | ||
## 16.5.0 - 2024-05-19 | ||
@@ -20,3 +28,3 @@ | ||
- Added timeout in `passportUtils.callUaa` call | ||
- Calculate the locationAfterLogin cookie when the path includes the hostname. | ||
- Calculate the locationAfterLogin cookie when the path includes the hostname | ||
- Validate zoneInfo API response | ||
@@ -23,0 +31,0 @@ |
@@ -116,3 +116,2 @@ 'use strict'; | ||
const cookies = { secure: routerConfig.secureSessionCookie }; | ||
let partitioningConfig; | ||
if (routerConfig.cookies){ | ||
@@ -122,7 +121,4 @@ if (routerConfig.cookies['SameSite']) { | ||
} | ||
if (routerConfig.cookies['Partitioned']) { | ||
partitioningConfig = routerConfig.cookies['Partitioned']; | ||
} | ||
} | ||
app.use(partitioned(partitioningConfig, expressSession({ | ||
app.use(partitioned(expressSession({ | ||
name: cookieName, | ||
@@ -129,0 +125,0 @@ resave: false, |
@@ -212,5 +212,5 @@ 'use strict'; | ||
function isHTML5RepoCredsExcluded(req){ | ||
let disabledHTML5RepoCredTenants; | ||
let disabledHTML5RepoCredTenants = false; | ||
if (process.env.DISABLE_HTML5_REPO_CREDENTIALS) { | ||
if (process.env.DISABLE_HTML5_REPO_CREDENTIALS === '*'){ | ||
if (process.env.DISABLE_HTML5_REPO_CREDENTIALS === '*') { | ||
disabledHTML5RepoCredTenants = true; | ||
@@ -221,4 +221,7 @@ } else { | ||
} | ||
return disabledHTML5RepoCredTenants; | ||
} | ||
if (!disabledHTML5RepoCredTenants && req.headers['x-disable-html5-repo-creds']){ | ||
disabledHTML5RepoCredTenants = true; | ||
} | ||
return disabledHTML5RepoCredTenants; | ||
} |
@@ -469,3 +469,3 @@ /* eslint-disable camelcase,max-depth */ | ||
} | ||
destinationUtils.getDestinationsByTenant(headerUtils.getCorrelationId(req), req.tenant, null, req.zoneInfo, req.app.services, function (err, subaccountDestinations) { | ||
destinationUtils.getDestinationsByTenant(headerUtils.getCorrelationId(req), req.tenant, null, req.zoneInfo, req.app.services,false, function (err, subaccountDestinations) { | ||
if (err) { | ||
@@ -479,8 +479,9 @@ return cb(err); | ||
} else { | ||
destinationUtils.getDestinationsByTenant(headerUtils.getCorrelationId(req), req.tenant, null, req.zoneInfo, req.app.services, function (err, subaccountDestinations) { | ||
if (err) { | ||
return cb(err); | ||
} | ||
cb(null, subaccountDestinations); | ||
}); | ||
destinationUtils.getDestinationsByTenant(headerUtils.getCorrelationId(req), req.tenant, null, req.zoneInfo, req.app.services,true | ||
, function (err, subaccountDestinations) { | ||
if (err) { | ||
return cb(err); | ||
} | ||
cb(null, subaccountDestinations); | ||
}); | ||
} | ||
@@ -487,0 +488,0 @@ } |
@@ -190,3 +190,3 @@ 'use strict'; | ||
const tenant = req.tenant.toLowerCase(); | ||
exports.getDestinationsByTenant(headerUtils.getCorrelationId(req), tenant, token, req.zoneInfo, req.app.services, function (err, destinations) { | ||
exports.getDestinationsByTenant(headerUtils.getCorrelationId(req), tenant, token, req.zoneInfo, req.app.services, false,function (err, destinations) { | ||
if (err) { | ||
@@ -339,4 +339,4 @@ return cb(err); | ||
function getDestinationsByTenant(correlationId, tenant, token, zoneInfo, services, cb) { | ||
getDestinationsByTenantReqOptions(correlationId, tenant, token, zoneInfo, services, function (error, requestOptions) { | ||
function getDestinationsByTenant(correlationId, tenant, token, zoneInfo, services,fetchSubscriberDest, cb) { | ||
getDestinationsByTenantReqOptions(correlationId, tenant, token, zoneInfo, services, fetchSubscriberDest,function (error, requestOptions) { | ||
if (error) { | ||
@@ -411,3 +411,3 @@ return cb(error); | ||
function getDestinationsByTenantReqOptions(correlationId, tenant, token, zoneInfo, services, cb) { | ||
function getDestinationsByTenantReqOptions(correlationId, tenant, token, zoneInfo, services,fetchSubscriberDest, cb) { | ||
let credentials = getDestinationServiceCredentials(); | ||
@@ -418,3 +418,3 @@ if (!credentials) { | ||
let url; | ||
if (process.env.MIGRATED_DEST === 'true'){ | ||
if (process.env.MIGRATED_DEST === 'true' && !fetchSubscriberDest){ | ||
url = `${credentials.uri}/destination-configuration/v1/subaccountDestinations?$filter=startswith(Name,'${tenant}')`; | ||
@@ -421,0 +421,0 @@ } else { |
@@ -353,3 +353,4 @@ 'use strict'; | ||
const bsKey = pathSegments[2] && exports.getApplicationKey(req,2); | ||
html5RepoUtils.attachCredentials(appKey.appPrefix, (bsKey && bsKey.appPrefix),appKey.appDestinationId, req); | ||
const contextId = appKey.appDestinationId || appKey.appNameWithoutPrefix; | ||
html5RepoUtils.attachCredentials(appKey.appPrefix, (bsKey && bsKey.appPrefix),contextId, req); | ||
appKey.bsKey = bsKey && bsKey.appPrefix && html5RepoUtils.getCredentials(bsKey.appPrefix,req) ? bsKey : undefined; | ||
@@ -356,0 +357,0 @@ } |
@@ -134,3 +134,5 @@ 'use strict'; | ||
const serviceKeyComponents = _getSapCloudServiceKeyComponents(sapCloudServiceKey, true); | ||
const apps = sapCloudServiceKeys[sapCloudServiceKey].applications; | ||
if ((contextId && contextId === serviceKeyComponents.appHostId && serviceKeyComponents.serviceName === mainServiceName) || | ||
(contextId && apps.find(app => app.applicationId === contextId || app.applicationName === contextId) && serviceKeyComponents.serviceName === mainServiceName) || | ||
(!contextId && serviceKeyComponents.serviceName === mainServiceName)) { | ||
@@ -137,0 +139,0 @@ serviceFound = true; |
'use strict'; | ||
module.exports = (config, middleware) => config ? (req, res, next) => { | ||
const re = /;\s*Partitioned\s*(;|$)/i; | ||
const partitioned = ' Partitioned'; | ||
const userAgent = req.headers['user-agent'] || ''; | ||
const _setHeader = res.setHeader; | ||
if (userAgent.match(config.supportedPartitionAgents) && !userAgent.match(config.unsupportedPartitionAgents)) { | ||
res.setHeader = function (key, val) { | ||
return _setHeader.call(res, key, key && key.toLowerCase() === 'set-cookie' && Array.isArray(val) ? | ||
val.map(v => v.match(re) ? v : v + (v.endsWith(';') ? partitioned : ';' + partitioned)) : | ||
val | ||
); | ||
}; | ||
module.exports = (middleware) => (req, res, next) => { | ||
const partitionedConfig = req.routerConfig && req.routerConfig.cookies && req.routerConfig.cookies['Partitioned']; | ||
if (partitionedConfig){ | ||
const re = /;\s*Partitioned\s*(;|$)/i; | ||
const partitioned = ' Partitioned'; | ||
const userAgent = req.headers['user-agent'] || ''; | ||
const _setHeader = res.setHeader; | ||
if (userAgent.match(partitionedConfig.supportedPartitionAgents) && !userAgent.match(partitionedConfig.unsupportedPartitionAgents)) { | ||
res.setHeader = function (key, val) { | ||
return _setHeader.call(res, key, key && key.toLowerCase() === 'set-cookie' && Array.isArray(val) ? | ||
val.map(v => v.match(re) ? v : v + (v.endsWith(';') ? partitioned : ';' + partitioned)) : | ||
val | ||
); | ||
}; | ||
} | ||
} | ||
return middleware(req, res, next); | ||
} : middleware; | ||
}; |
{ | ||
"name": "@sap/approuter", | ||
"description": "Node.js based application router", | ||
"version": "16.5.0", | ||
"version": "16.5.1", | ||
"repository": {}, | ||
@@ -6,0 +6,0 @@ "main": "approuter.js", |
731562
11899