‎2024 Sep 16 6:21 AM - edited ‎2024 Sep 16 6:27 AM
Hi there,
I have a fastapi app with 2 routes, one for rendering an html page and one for serving a request. I am using Jinja2 for templating.
Example of one of the route:
@router.get("/", response_class=HTMLResponse)
async def read_root(request: Request):
return templates.TemplateResponse("index.html", {"request": request})My manifest.yaml for deploying it to cloud foundry:
---
applications:
- name: fastapi-app
disk_quota: 2048M
memory: 256M
path: ./
routes:
- route: fastapi-app.cfapps.eu10.hana.ondemand.com
buildpacks:
- python_buildpack
command: uvicorn com.crack.snap.make.app:app --host 0.0.0.0 --port $PORT
services:
- app-xsuaa
- app-logging-service
logging:
level: error
env:
PYTHONUNBUFFERED: true
xsuaa_connectivity_instance_name: "app-xsuaa"
xsuaa_destination_instance_name: "app-xsuaa"How do I protect these fastapi routes directly using XSUAA, without having to create one more webapp then use app-router and then forwarding the request to fastapi app?
Also I want the fastapi to use the sub-account's default authentication which we do by using redirect-url of xs-security.json
{
"xsappname": "fastapi-app",
"tenant-mode": "dedicated",
"scopes": [{
"name": "$XSAPPNAME.fastapi_scope"
}],
"role-templates": [{
"name": "FastAPIRoleTemplate",
"default-role-name": "FastAPIRole",
"description": "Role template for app users",
"scope-references": ["$XSAPPNAME.fastapi_scope"]
}
],
"oauth2-configuration": {
"redirect-uris": [
"https://*.cfapps.eu10.hana.ondemand.com/**"
]
}
}Any help on achieving this will be really appreciated, we can also have a blog post on the same topic
SAP BTP, Cloud Foundry runtime and environment Python SAP BTP Security
Request clarification before answering.
The tutorial Create an Application with Cloud Foundry Python Buildpack provides an example using Flask. Maybe you can adopt that to FastAPI. Would be great if you share it afterwards.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 15 | |
| 9 | |
| 6 | |
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.