@sap/approuter
Advanced tools
Comparing version 5.11.0 to 5.13.0
@@ -8,2 +8,12 @@ # Change Log | ||
## 5.13.0 - 2019-02-14 | ||
### Added | ||
- Ability to define identity provider for authentication in the route. | ||
## 5.12.0 - 2019-02-05 | ||
### Added | ||
- Dynamic destination support. | ||
## 5.11.0 - 2019-01-22 | ||
@@ -10,0 +20,0 @@ |
@@ -32,2 +32,3 @@ { | ||
"authenticationType": { "type": "string", "enum": ["xsuaa", "basic", "none"] }, | ||
"identityProvider": { "type": "string", "minLength": 1}, | ||
"scope": { "$ref": "scopesSchema" }, | ||
@@ -34,0 +35,0 @@ "replace": { |
@@ -100,3 +100,5 @@ 'use strict'; | ||
} | ||
if (route.identityProvider && route.authenticationType && route.authenticationType !== 'xsuaa'){ | ||
return 'Route has both identityProvider and authenticationType that is not of type \'xsuaa\''; | ||
} | ||
if (route.localDir) { | ||
@@ -103,0 +105,0 @@ var fullPath = path.join(directory, route.localDir); |
@@ -68,2 +68,3 @@ 'use strict'; | ||
if (destination) { | ||
destination = !destination.startsWith('$') ? destination : url.replace(route.source, route.destination); | ||
var oDestination = routerConfig.destinations[destination] ? | ||
@@ -87,2 +88,3 @@ routerConfig.destinations[destination] : {url: 'DESTINATION_URL_PLACEHOLDER', name: destination}; | ||
rewrittenUrl.route = route; | ||
rewrittenUrl.route.destination = destination; | ||
if (useService && credentials){ | ||
@@ -89,0 +91,0 @@ rewrittenUrl.route.credentials = credentials; |
@@ -44,3 +44,3 @@ 'use strict'; | ||
var logger = loggingContext.getLogger('/Auth/OAuth2'); | ||
var location = this._oauth2.getCodeAuthorizationUrl(authorizationURL, callbackURL); | ||
var location = this._oauth2.getCodeAuthorizationUrl(req, authorizationURL, callbackURL); | ||
if (process.env.PRESERVE_FRAGMENT !== 'false') { | ||
@@ -47,0 +47,0 @@ logger.info('sending page with client-side redirect to %s', location); |
@@ -22,8 +22,14 @@ 'use strict'; | ||
OAuth2.prototype.getCodeAuthorizationUrl = function (authorizationURL, callbackURL) { | ||
return authorizationURL + '?' + querystring.stringify({ | ||
OAuth2.prototype.getCodeAuthorizationUrl = function (req, authorizationURL, callbackURL) { | ||
var authURLQuery = { | ||
'response_type': 'code', | ||
'client_id': this._options.clientid, | ||
'redirect_uri': callbackURL | ||
}); | ||
}; | ||
if (req.internalUrl && req.internalUrl.route && req.internalUrl.route.identityProvider) { | ||
authURLQuery['login_hint'] = JSON.stringify({ | ||
origin: req.internalUrl.route.identityProvider | ||
}); | ||
} | ||
return authorizationURL + '?' + querystring.stringify(authURLQuery); | ||
}; | ||
@@ -30,0 +36,0 @@ |
@@ -64,11 +64,15 @@ 'use strict'; | ||
} | ||
obtainDestinationServiceToken(token, credentials, options, function(err, token) { | ||
if (err){ | ||
return cb(err); | ||
} | ||
headers.Authorization = 'Bearer ' + token; | ||
cb (null, { | ||
url: credentials.uri + '/destination-configuration/v1/destinations/' + destinationName, | ||
headers: headers | ||
}); | ||
var auth; | ||
if (token){ | ||
auth = token; | ||
} else if (options && options.app && options.app.services['destination'] && options.app.services['destination'].token){ | ||
auth = options.app.services['destination'].token.accessToken; | ||
} else { | ||
return cb('obtain token error'); | ||
} | ||
headers.Authorization = 'Bearer ' + auth; | ||
return cb (null, { | ||
url: credentials.uri + '/destination-configuration/v1/destinations/' + destinationName, | ||
headers: headers | ||
}); | ||
@@ -107,3 +111,2 @@ } | ||
if (errorOccurred || !credentials) { | ||
logger.error('Error during loading of destination service credentials. Verify Destination service is bound'); | ||
return null; | ||
@@ -114,15 +117,2 @@ } | ||
function obtainDestinationServiceToken (token, credentials, options, cb) { | ||
// this is the case when exchange token performed and we have token of destination service | ||
if (token){ | ||
return cb (null, token); | ||
} else { | ||
// this is the case when the session is not authenticated, so there were no exchange token. | ||
// in this case we have to get the token of destination using its client credentials | ||
return cb (null, options.app.services['destination'].token); | ||
} | ||
} | ||
// Finds a destination by name on all levels and returns the first match | ||
@@ -129,0 +119,0 @@ // Search priority is destination on instance level and after that fallback to the shared destinations on subaccount level. |
@@ -1,1 +0,1 @@ | ||
{"bundleDependencies":false,"dependencies":{"@sap/audit-logging":"2.2.4","@sap/e2e-trace":"1.3.0","@sap/logging":"4.0.2","@sap/xsenv":"1.2.8","@sap/xssec":"2.1.15","agentkeepalive":"2.0.5","async":"2.0.1","base64-url":"2.0.0","basic-auth":"1.0.3","body-parser":"1.18.3","commander":"2.9.0","compression":"1.7.3","connect":"3.6.5","cookie":"0.2.2","cookie-parser":"1.3.5","cookie-signature":"1.1.0","debug":"3.1.0","deepmerge":"2.1.1","encodeurl":"1.0.2","express-session":"1.15.6","http-proxy-agent":"2.1.0","https-proxy-agent":"2.2.0","jwt-decode":"2.0.1","lodash":"4.17.11","lru-cache":"4.0.0","mime":"1.4.1","moment":"2.19.3","ms":"2.1.1","mustache":"2.2.1","node-cache":"4.1.1","passport":"0.3.2","request":"2.87.0","request-stats":"2.0.1","safe-regex":"1.1.0","scmp":"1.0.0","send":"0.16.2","serve-static":"1.13.2","tough-cookie":"2.3.3","tv4":"1.2.7","uid-safe":"2.1.5","urijs":"1.16.1","uuid":"3.2.1","verror":"1.10.0","ws":"1.1.5"},"deprecated":false,"description":"Node.js based application router","devDependencies":{"chai":"3.5.0","diveSync":"0.3.0","eslint":"3.2.2","express":"4.16.2","filter-node-package":"2.0.0","istanbul":"0.4.4","markdown-toc":"1.1.0","mocha":"3.0.2","mock-require":"3.0.2","node-build":"1.0.0","node-mocks-http":"1.5.2","node-style":"^2.0.0","proxyquire":"1.7.10","rewire":"2.5.2","rimraf":"2.5.4","sinon":"1.17.5","supertest":"3.3.0"},"engines":{"node":"^4.5.0 || ^6.0.0 "},"main":"approuter.js","name":"@sap/approuter","repository":{},"scripts":{"lint":"eslint -c node_modules/node-style/.eslintrc -f stylish lib/ approuter.js","prepareRelease":"node build/delete-extra-packages.js && clean-packages && npm prune --production","start":"node approuter.js","test":"node build/test","toc":"markdown-toc -i README.md && markdown-toc -i doc/extending.md && markdown-toc -i doc/sizingGuide.md"},"version":"5.11.0","warnings":[{"code":"ENOTSUP","required":{"node":"^4.5.0 || ^6.0.0 "},"pkgid":"@sap/approuter@5.11.0"},{"code":"ENOTSUP","required":{"node":"^4.5.0 || ^6.0.0 "},"pkgid":"@sap/approuter@5.11.0"}],"license":"SEE LICENSE IN developer-license-3.1.txt"} | ||
{"bundleDependencies":false,"dependencies":{"@sap/audit-logging":"2.2.4","@sap/e2e-trace":"1.3.0","@sap/logging":"4.0.2","@sap/xsenv":"1.2.8","@sap/xssec":"2.1.15","agentkeepalive":"2.0.5","async":"2.0.1","base64-url":"2.0.0","basic-auth":"1.0.3","body-parser":"1.18.3","commander":"2.9.0","compression":"1.7.3","connect":"3.6.5","cookie":"0.2.2","cookie-parser":"1.3.5","cookie-signature":"1.1.0","debug":"3.1.0","deepmerge":"2.1.1","encodeurl":"1.0.2","express-session":"1.15.6","http-proxy-agent":"2.1.0","https-proxy-agent":"2.2.0","jwt-decode":"2.0.1","lodash":"4.17.11","lru-cache":"4.0.0","mime":"1.4.1","moment":"2.19.3","ms":"2.1.1","mustache":"2.2.1","node-cache":"4.1.1","passport":"0.3.2","request":"2.87.0","request-stats":"2.0.1","safe-regex":"1.1.0","scmp":"1.0.0","send":"0.16.2","serve-static":"1.13.2","tough-cookie":"2.3.3","tv4":"1.2.7","uid-safe":"2.1.5","urijs":"1.16.1","uuid":"3.2.1","verror":"1.10.0","ws":"1.1.5"},"deprecated":false,"description":"Node.js based application router","devDependencies":{"chai":"3.5.0","diveSync":"0.3.0","eslint":"3.2.2","express":"4.16.2","filter-node-package":"2.0.0","gulp":"^3.9.1","gulp-eslint":"^4.0.0","gulp-mocha":"^4.3.1","istanbul":"0.4.4","markdown-toc":"1.1.0","mocha":"3.0.2","mock-require":"3.0.2","node-build":"1.0.0","node-mocks-http":"1.5.2","node-style":"^2.0.0","proxyquire":"1.7.10","rewire":"2.5.2","rimraf":"2.5.4","sinon":"1.17.5","sonarqube-scanner":"^2.1.2","supertest":"3.3.0"},"engines":{"node":"^4.5.0 || ^6.0.0 "},"main":"approuter.js","name":"@sap/approuter","repository":{},"scripts":{"lint":"eslint -c node_modules/node-style/.eslintrc -f stylish lib/ approuter.js","prepareRelease":"node build/delete-extra-packages.js && clean-packages && npm prune --production","sonar":"gulp sonarqube","start":"node approuter.js","test":"node build/test","toc":"markdown-toc -i README.md && markdown-toc -i doc/extending.md && markdown-toc -i doc/sizingGuide.md"},"version":"5.13.0","warnings":[{"code":"ENOTSUP","required":{"node":"^4.5.0 || ^6.0.0 "},"pkgid":"@sap/approuter@5.13.0"},{"code":"ENOTSUP","required":{"node":"^4.5.0 || ^6.0.0 "},"pkgid":"@sap/approuter@5.13.0"}],"license":"SEE LICENSE IN developer-license-3.1.txt"} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
1031817
5938
1865
21