Skip to content

Commit

Permalink
fastapi-dls: init at 1.4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
MakiseKurisu committed Dec 10, 2024
1 parent 7243daf commit 71e6e52
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 0 deletions.
10 changes: 10 additions & 0 deletions pkgs/by-name/fa/fastapi-dls/add-algorithms-argument.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
--- a/app/main.py
+++ b/app/main.py
@@ -340,7 +340,7 @@
j, cur_time = json_loads((await request.body()).decode('utf-8')), datetime.utcnow()

try:
- payload = jwt.decode(token=j.get('auth_code'), key=jwt_decode_key)
+ payload = jwt.decode(token=j.get('auth_code'), key=jwt_decode_key, algorithms=ALGORITHMS.RS256)
except JWTError as e:
return JSONr(status_code=400, content={'status': 400, 'title': 'invalid token', 'detail': str(e)})
73 changes: 73 additions & 0 deletions pkgs/by-name/fa/fastapi-dls/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{
lib,
python3,
fetchFromGitLab,
gitUpdater,
makeWrapper,
}:

let

pythonEnv = python3.withPackages (
packages:
with packages;
[
fastapi
uvicorn
python-jose
pycryptodome
python-dateutil
sqlalchemy
markdown
python-dotenv
]
++ uvicorn.optional-dependencies.standard
);

version = "1.4.1";

in
python3.pkgs.buildPythonApplication {
pname = "fastapi-dls";
inherit version;
pyproject = false;

src = fetchFromGitLab {
domain = "git.collinwebdesigns.de";
owner = "oscar.krause";
repo = "fastapi-dls";
rev = "refs/tags/${version}";
hash = "sha256-H4mtmJ4iQXPZFWQPm12aH/kdg9TAMgHkvkbaHfxfS3I=";
};

patches = [
./add-algorithms-argument.patch # fixes license activation
];

# Don't create .orig files if the patch isn't an exact match.
patchFlags = [
"--no-backup-if-mismatch"
"-p1"
];

postInstall = ''
mkdir -p $out/bin $out/share/fastapi-dls
cp -r README.md app $out/share/fastapi-dls
makeWrapper ${pythonEnv}/bin/uvicorn $out/bin/fastapi-dls \
--add-flags "--app-dir $out/share/fastapi-dls/app" \
--add-flags "--proxy-headers" \
--add-flags "main:app"
'';

passthru.updateScript = gitUpdater { };

meta = {
description = "Minimal Delegated License Service (DLS)";
homepage = "https://git.collinwebdesigns.de/oscar.krause/fastapi-dls";
license = lib.licenses.unfree;
mainProgram = "fastapi-dls";
platforms = lib.platforms.linux;
maintainers = with lib.maintainers; [ MakiseKurisu ];
};
}

0 comments on commit 71e6e52

Please sign in to comment.