
@Sisn/approuter
, to act as an entry point for the Python application. As shown in the structure below, all the requests that come to the Application Router will trigger the process of authentication (and authorization). By default, the IdP is the pre-provided identity provider. You can also add your customized IdP as an identity provider as well. xs-security.json
file for your application with the following content:{
"xsappname":"myapp",
"tenant-mode":"dedicated",
"oauth2-configuration":{
"redirect-uris":[
"https://*.<custom-domain>/**"
]
}
}
cf domains
.{
"xsappname":"myapp",
"tenant-mode":"dedicated",
"oauth2-configuration":{
"redirect-uris":[
"https://*.apps.sap-samples.scpcloud.top/**"
]
}
}
myuaa
via the following command:cf create-service xsuaa application myuaa -c xs-security.json
myuaa
service instance into the manifest.yml
file as following:---
applications:
- name: myapp
host: <host>
path: .
domain: <custom-domain>
memory: 128M
command: python server.py
services:
- myuaa
myuaa
service instance will be bound to the myapp
application during deployment later.approuter
in the python-with-xsuaa
directory.approuter
directory, create a sub-directory named resources
, this directory will be used to provide the business application's static resources.resources
, create an index.html
file with the following content:<html>
<head>
<title>Python with XSUAA</title>
</head>
<body>
<h1>Python with XSUAA</h1>
<a href="https://blogs.sap.com/myapp/">myapp</a>
</body>
</html>
package.json
file in the approuter
directory by executing:npm init
approuter
packages into the approuter/node_modules/@sap
by executing:npm install @sap/approuter --save
package.json
file in the approuter
directory:"scripts": {
"start": "node node_modules/@sap/approuter/approuter.js"
}
{
"name": "approuter",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "node node_modules/@sap/approuter/approuter.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"@sap/approuter": "^8.0.0"
}
}
manifest.yml
file in the python-with-xsuaa
directory with the following content at the end of it:---
applications:
- name: myapp
host: <host>
path: .
domain: <custom-domain>
memory: 128M
command: python server.py
services:
- myuaa
- name: approuter
host: <host>
path: approuter
domain: <custom-domain>
memory: 128M
env:
destinations: >
[
{
"name":"myapp",
"url":"<myapp-url>",
"forwardAuthToken": true
}
]
services:
- myuaa
cf domains
.myapp
application as displayed by the cf apps
command, and add the network protocol before the URL.---
applications:
- name: myapp
host: myapp-ixxxxxx
path: .
domain: apps.sap-samples.scpcloud.top
memory: 128M
command: python server.py
services:
- myuaa
- name: approuter
host: approuter-ixxxxxx
path: approuter
domain: apps.sap-samples.scpcloud.top
memory: 128M
env:
destinations: >
[
{
"name":"myapp",
"url":"https://myapp-ixxxxxx.apps.sap-samples.scpcloud.top",
"forwardAuthToken": true
}
]
services:
- myuaa
xs-app.json
file in the approuter
directory with the following content:{
"routes": [
{
"source": "^/myapp/(.*)$",
"target": "$1",
"destination": "myapp"
}
]
}
python-with-xsuaa
directory and execute:cf push
myapp
application and deploy the new approuter
application as well.approuter
application will be requested instead of the myapp
URL. It will then forward the requests to the myapp
application.approuter
application via:cf apps
approuter
application, you should see the logon page for authentication:approuter
application:myapp
link, you can see your myapp
application:This blog post shared how to leverage the Application Router and the XSUAA service in SAP Cloud Platform to realize authentication onto an existed app.
redirect-uris
needs to be specified in xs-security.json
file.You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
7 | |
7 | |
7 | |
7 | |
6 | |
5 | |
5 | |
5 | |
5 | |
5 |