Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

authentik: Fix runtime errors #329151

Merged
merged 1 commit into from
Jul 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 48 additions & 5 deletions pkgs/by-name/au/authentik/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
, stdenvNoCC
, callPackages
, fetchFromGitHub
, fetchpatch
, fetchzip
, buildNpmPackage
, buildGoModule
Expand Down Expand Up @@ -178,6 +179,40 @@ let
pyproject = true;
};

# Use 3.14.0 until https://github.com/encode/django-rest-framework/issues/9358 is fixed.
# Otherwise applying blueprints/default/default-brand.yaml fails with:
# authentik.flows.models.RelatedObjectDoesNotExist: FlowStageBinding has no target.
djangorestframework = prev.buildPythonPackage rec {
pname = "djangorestframework";
version = "3.14.0";
format = "setuptools";

src = fetchFromGitHub {
owner = "encode";
repo = "django-rest-framework";
rev = version;
hash = "sha256-Fnj0n3NS3SetOlwSmGkLE979vNJnYE6i6xwVBslpNz4=";
};

propagatedBuildInputs = with final; [
django
pytz
];

nativeCheckInputs = with final; [
pytest-django
pytest7CheckHook

# optional tests
coreapi
django-guardian
pyyaml
uritemplate
];

pythonImportsCheck = [ "rest_framework" ];
};

tenant-schemas-celery = prev.buildPythonPackage rec {
pname = "tenant-schemas-celery";
version = "3.0.0";
Expand Down Expand Up @@ -225,16 +260,23 @@ let
inherit version src meta;
pyproject = true;

patches = [
(fetchpatch {
name = "scim-schema-load.patch";
url = "https://github.com/goauthentik/authentik/commit/f3640bd3c0ee2f43efcfd506bb71d2b7b6761017.patch";
hash = "sha256-4AC7Dc4TM7ok964ztc+XdHvoU/DKyi9yJoz5u1dljEM=";
})
];

postPatch = ''
rm lifecycle/system_migrations/tenant_files.py
substituteInPlace authentik/root/settings.py \
--replace-fail 'Path(__file__).absolute().parent.parent.parent' "\"$out\""
--replace-fail 'Path(__file__).absolute().parent.parent.parent' "Path(\"$out\")"
substituteInPlace authentik/lib/default.yml \
--replace-fail '/blueprints' "$out/blueprints" \
--replace-fail './media' '/var/lib/authentik/media'
substituteInPlace pyproject.toml \
--replace-fail 'dumb-init = "*"' "" \
--replace-fail 'djangorestframework = "3.14.0"' 'djangorestframework = "*"' \
--replace-fail 'djangorestframework-guardian' 'djangorestframework-guardian2'
substituteInPlace authentik/stages/email/utils.py \
--replace-fail 'web/' '${webui}/'
Expand Down Expand Up @@ -306,16 +348,17 @@ let
wsproto
xmlsec
zxcvbn
] ++ [
codespell
];
]
++ uvicorn.optional-dependencies.standard
++ [ codespell ];

postInstall = ''
mkdir -p $out/web $out/website
cp -r lifecycle manage.py $out/${prev.python.sitePackages}/
cp -r blueprints $out/
cp -r ${webui}/dist ${webui}/authentik $out/web/
cp -r ${website} $out/website/help
ln -s $out/${prev.python.sitePackages}/authentik $out/authentik
ln -s $out/${prev.python.sitePackages}/lifecycle $out/lifecycle
'';
};
Expand Down