resources:
- name: basicnodejs-xsuaa
type: org.cloudfoundry.managed-service
parameters:
service: xsuaa
service-plan: application
config:
xsappname: basicnodejs-${org}-${space}
tenant-mode: dedicated
ID: basicnodejs
_schema-version: '3.1'
version: 0.0.1
parameters:
enable-parallel-deployments: true
modules:
- name: basicnodejs-service
type: nodejs
path: srv
build-parameters:
ignore:
- 'default-*.json'
- .env
- '*node_modules*'
- package-lock.json
provides:
- name: srv-api
properties:
srv-url: ${default-url}
requires:
- name: basicnodejs-xsuaa
- name: basicnodejs-approuter
type: approuter.nodejs
path: app
build-parameters:
ignore:
- 'default-*.json'
- .env
- '*node_modules*'
- package-lock.json
parameters:
memory: 256M
disk-quota: 512M
keep-existing-routes: true
requires:
- name: srv-api
group: destinations
properties:
name: srv-api # must be used in xs-app.json as well
url: ~{srv-url}
forwardAuthToken: true
- name: basicnodejs-xsuaa
resources:
- name: basicnodejs-xsuaa
type: org.cloudfoundry.managed-service
parameters:
service: xsuaa
service-plan: application
config:
xsappname: basicnodejs-${org}-${space}
tenant-mode: dedicated
{
"authenticationMethod": "route",
"routes": [{
"source": "^/(.*)$",
"target": "$1",
"destination": "srv-api"
}]
}
resources:
- name: basicnodejs-xsuaa
type: org.cloudfoundry.managed-service
parameters:
service: xsuaa
service-plan: application
config:
xsappname: basicnodejs-${org}-${space}
tenant-mode: dedicated
oauth2-configuration:
redirect-uris:
- "https://*.hana.ondemand.com/**"
npm install @sap/xsenv @sap/xssec passport
const express = require("express");
const passport = require("passport");
const xsenv = require("@sap/xsenv");
const JWTStrategy = require("@sap/xssec").JWTStrategy;
const services = xsenv.getServices({ uaa:"basicnodejs-xsuaa" }); // XSUAA service
const app = express();
passport.use(new JWTStrategy(services.uaa));
app.use(passport.initialize());
app.use(passport.authenticate("JWT", { session: false }));
app.get("/", function (req, res, next) {
res.send("Welcome User: " + req.user.name.givenName);
});
const port = process.env.PORT || 5000;
app.listen(port, function () {
console.log("Basic NodeJs listening on port " + port);
});
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
13 | |
10 | |
7 | |
7 | |
6 | |
5 | |
5 | |
5 | |
4 | |
4 |