From 1682801e642199df6e36ee1b2d30386784b65b0c Mon Sep 17 00:00:00 2001
From: Anis Koubaa <mohamed.koubaa@kit.edu>
Date: Thu, 27 Feb 2025 09:27:13 +0100
Subject: [PATCH] implement Authentication.

---
 services/README.md                     |  7 ++++++-
 services/backend_regimo/pyproject.toml | 28 --------------------------
 services/backend_regimo/src/main.py    | 20 +++++++++---------
 3 files changed, 16 insertions(+), 39 deletions(-)
 delete mode 100644 services/backend_regimo/pyproject.toml

diff --git a/services/README.md b/services/README.md
index 989d1c7..934f1b1 100644
--- a/services/README.md
+++ b/services/README.md
@@ -4,4 +4,9 @@
 A user plugs in the EDR at a certain location, connects it with its laptop and starts the recording of a campaign. At the same time the user starts the publishing tool REGIMO (from this git repository). All new created files are tracked by the tool and automatically uploaded to the cloud and then published to the databus using its cloud URL.
 
 ### Use Case #2 (Secondary use case)
-The existing database of the EDR is analyzed and all existing valid data sets (correct filesystem structure and metadata json files exist) get published to the cloud and registered in the databus.
\ No newline at end of file
+The existing database of the EDR is analyzed and all existing valid data sets (correct filesystem structure and metadata json files exist) get published to the cloud and registered in the databus.
+
+### use
+poetry export --without-hashes --format=requirements.txt > requirements.txt
+
+to export an actual requirements.txt
\ No newline at end of file
diff --git a/services/backend_regimo/pyproject.toml b/services/backend_regimo/pyproject.toml
deleted file mode 100644
index 83eb5a8..0000000
--- a/services/backend_regimo/pyproject.toml
+++ /dev/null
@@ -1,28 +0,0 @@
-[tool.poetry]
-name = "backend_regimo"
-version = "0.1.0"
-description = "This is the backend for Regimo. Regimo is a tool to register data on a databus."
-authors = ["Anis Koubaa <mohamed.koubaa@kit.edu>"]
-license = "MIT"
-readme = "README.md"
-
-[tool.poetry.dependencies]
-python = "^3.10"
-fastapi = "^0.100.0"
-uvicorn = "^0.24.0"
-oep-client = "^0.17.0"
-openpyxl = "^3.1.5"
-omi = "^0.2.0"
-pyjwt = "^2.10.1"
-
-[tool.poetry.group.test.dependencies]
-pytest = "^8"
-
-
-[tool.poetry.group.dev.dependencies]
-datamodel-code-generator = "^0.26.5"
-reuse = "^5.0.2"
-
-[build-system]
-requires = ["poetry-core"]
-build-backend = "poetry.core.masonry.api"
\ No newline at end of file
diff --git a/services/backend_regimo/src/main.py b/services/backend_regimo/src/main.py
index 931d628..650b515 100644
--- a/services/backend_regimo/src/main.py
+++ b/services/backend_regimo/src/main.py
@@ -1,22 +1,22 @@
-from fastapi import FastAPI
-from fastapi.middleware.cors import CORSMiddleware
+from fastapi import Depends, FastAPI
+from fastapi.security import OAuth2PasswordBearer
+from typing import Annotated
 
 app = FastAPI()
 
-app.add_middleware(
-    CORSMiddleware,
-    allow_origins=["http://localhost:8080"],
-    allow_credentials=True,
-    allow_methods=["*"],
-    allow_headers=["*"],
-)
+oauth2_scheme = OAuth2PasswordBearer(tokenUrl="token")
 
 
 @app.get("/")
 def home():
-    return "Hello, World!"
+    return "Hello, my secure World!"
 
 
 @app.get("/manifest")
 def get_artifacts():
     return "Here are some artifacts"
+
+
+@app.get("/items/")
+async def read_items(token: Annotated[str, Depends(oauth2_scheme)]):
+    return {"token": token}
\ No newline at end of file
-- 
GitLab