タイトルが示すように、Cloud Foundry の FLP にあるアプリケーションからユーザー情報を取得しようとしています。
次のブログをフォローしました: https://blogs.sap.com/2019/05/23/how-to-get-the-email-of-the-logged-in-user-in-cloud-foundry/
ただし、私のアプリケーション構造は異なり、それを機能させる方法がわかりません。
まず、プロジェクトの作成を次の 2 つのリンクに要約できます。
- https://developers.sap.com/tutorials/cp-ui5-webide-new-app.html
- https://developers.sap.com/tutorials/cp-portal-cloud-foundry-create-launchpad.html
私のアプリケーションの構造は次のとおりです。
関連付けられた mta.yaml を使用:
ID: mta_ztransport_appointment
_schema-version: '2.1'
parameters:
deploy_mode: html5-repo
version: 0.0.1
modules:
- name: mta-ztransport-appointment-approuter
type: approuter.nodejs
path: mta-ztransport-appointment-approuter
parameters:
disk-quota: 256M
memory: 128M
requires:
- name: mta_ztransport_appointment_html5_repo_runtime
- name: uaa_mta_ztransport_appointment
- name: portal_resources_mta_ztransport_appointment
- name: dest_mta_ztransport_appointment
- name: conn_mta_ztransport_appointment
- name: mta_ztransport_appointment_ui_deployer
type: com.sap.html5.application-content
path: mta_ztransport_appointment_ui_deployer
requires:
- name: mta_ztransport_appointment_html5_repo_host
build-parameters:
requires:
- name: ztransport.appointment
artifacts:
- './*'
target-path: resources/ztransport.appointment
- name: ztransport.appointment
type: html5
path: ztransport.appointment
build-parameters:
builder: custom
commands:
- npm install
- npm run build
supported-platforms: []
build-result: dist
- name: flp
type: com.sap.portal.content
path: flp
parameters:
stack: cflinuxfs3
memory: 128M
buildpack: 'https://github.com/cloudfoundry/nodejs-buildpack/releases/download/v1.6.39/nodejs-buildpack-cflinuxfs3-v1.6.39.zip'
requires:
- name: portal_resources_mta_ztransport_appointment
- name: uaa_mta_ztransport_appointment
- name: mta_ztransport_appointment_html5_repo_host
- name: mta_ztransport_appointment_ui_deployer
resources:
- name: mta_ztransport_appointment_html5_repo_runtime
parameters:
service-plan: app-runtime
service: html5-apps-repo
type: org.cloudfoundry.managed-service
- name: mta_ztransport_appointment_html5_repo_host
parameters:
service-plan: app-host
service: html5-apps-repo
type: org.cloudfoundry.managed-service
- name: uaa_mta_ztransport_appointment
parameters:
path: ./xs-security.json
service-plan: application
service: xsuaa
type: org.cloudfoundry.managed-service
- name: dest_mta_ztransport_appointment
parameters:
service-plan: lite
service: destination
type: org.cloudfoundry.managed-service
- name: portal_resources_mta_ztransport_appointment
parameters:
service-plan: standard
service: portal
type: org.cloudfoundry.managed-service
- name: conn_mta_ztransport_appointment
parameters:
service-plan: lite
service: connectivity
type: org.cloudfoundry.managed-service
xs-security.json ファイル:
{
"xsappname": "mta_ztransport_appointment",
"tenant-mode": "dedicated",
"description": "Security profile of called application",
"scopes": [{
"name": "$XSAPPNAME.Display",
"description": "display"
}, {
"name": "$XSAPPNAME.Update",
"description": "update"
}, {
"name": "uaa.user",
"description": "UAA"
}],
"role-templates": [{
"name": "Token_Exchange",
"description": "UAA",
"scope-references": [
"uaa.user"
]
}, {
"name": "Viewer",
"description": "View Users",
"scope-references": [
"$XSAPPNAME.Display"
]
}, {
"name": "Manager",
"description": "Maintain Users",
"scope-references": [
"$XSAPPNAME.Display",
"$XSAPPNAME.Update"
]
}]
}
approuter フォルダー内の xs-app.json:
{
"welcomeFile": "/cp.portal",
"authenticationMethod": "route",
"logout": {
"logoutEndpoint": "/do/logout"
},
"routes": [
{
"source": "^/Dirickx_DE1/(.*)$",
"target": "$1",
"authenticationType": "none",
"destination": "Dirickx_DE1",
"csrfProtection": false
},
{
"source": "^(.*)$",
"target": "$1",
"service": "html5-apps-repo-rt",
"authenticationType": "xsuaa"
}
]
}
approuter フォルダーに入れられたブログとまったく同じ approuter-start.js です。
var approuter = require('@sap/approuter');
var ar = approuter();
ar.beforeRequestHandler.use('/getuserinfo', function (req, res, next) {
if (!req.user) {
res.statusCode = 403;
res.end("Missing JWT Token");
} else {
res.statusCode = 200;
res.end("My name is ${JSON.stringify(req.user.name, null, 2)}");
}
});
ar.start();
approuter フォルダー内の package.json は次のようになります。
{
"name": "html5-apps-approuter",
"description": "Node.js based application router service for html5-apps",
"engines": {
"node": "^8.0.0 || ^10.0.0"
},
"dependencies": {
"@sap/approuter": "6.8.0"
},
"scripts": {
"start": "node ./approuter-start.js"
}
}
私の xs-app.json ファイルはブログのファイルとは異なり、エラーが原因だと思いますが、ブログに固執するとデプロイに失敗します。私が使用しているものでは、展開は機能しますが、要求は行われません。
何か案が?ありがとう