10 , openapi-generator-cli
19 src = fetchFromGitHub {
20 owner = "goauthentik";
22 rev = "version/${version}";
23 hash = "sha256-QwK/auMLCJEHHtyexFnO+adCq/u0fezHQ90fXW9J4c4=";
27 description = "Authentication glue you need";
28 changelog = "https://github.com/goauthentik/authentik/releases/tag/version%2F${version}";
29 homepage = "https://goauthentik.io/";
30 license = licenses.mit;
31 platforms = platforms.linux;
32 maintainers = with maintainers; [ jvanbruegge risson ];
33 knownVulnerabilities = [
37 "Authentik 2024.6.x is end-of-life, consider using https://github.com/nix-community/authentik-nix for an up-to-date alternative"
41 website = buildNpmPackage {
42 pname = "authentik-website";
43 inherit version src meta;
44 npmDepsHash = "sha256-JM+ae+zDsMdvovd2p4IJIH89KlMeDU7HOZjFbDCyehw=";
46 NODE_ENV = "production";
47 NODE_OPTIONS = "--openssl-legacy-provider";
58 npmBuildScript = "build-bundled";
59 npmFlags = [ "--ignore-scripts" ];
62 clientapi = stdenvNoCC.mkDerivation {
63 pname = "authentik-client-api";
64 inherit version src meta;
69 substituteInPlace ./scripts/api-ts-config.yaml \
70 --replace-fail '/local' "$(pwd)/"
73 nativeBuildInputs = [ openapi-generator-cli ];
76 openapi-generator-cli generate -i ./schema.yml \
77 -g typescript-fetch -o $out \
78 -c ./scripts/api-ts-config.yaml \
79 --additional-properties=npmVersion="$(${lib.getExe' nodejs "npm"} --version)" \
80 --git-repo-id authentik --git-user-id goauthentik
85 webui = buildNpmPackage {
86 pname = "authentik-webui";
89 src = runCommand "authentik-webui-source" {} ''
90 mkdir -p $out/web/node_modules/@goauthentik/
91 cp -r ${src}/web $out/
92 ln -s ${src}/package.json $out/
93 ln -s ${src}/website $out/
94 ln -s ${clientapi} $out/web/node_modules/@goauthentik/api
96 npmDepsHash = "sha256-8TzB3ylZzVLePD86of8E/lGgIQCciWMQF9m1Iqv9ZTY=";
106 cp -r authentik $out/authentik
110 NODE_ENV = "production";
111 NODE_OPTIONS = "--openssl-legacy-provider";
113 npmInstallFlags = [ "--include=dev" ];
116 python = python312.override {
118 packageOverrides = final: prev: {
119 django-tenants = prev.django-tenants.overrideAttrs {
120 version = "3.6.1-unstable-2024-01-11";
121 src = fetchFromGitHub {
123 repo = "django-tenants";
124 rev = "a7f37c53f62f355a00142473ff1e3451bb794eca";
125 hash = "sha256-YBT0kcCfETXZe0j7/f1YipNIuRrcppRVh1ecFS3cvNo=";
128 # Use 3.14.0 until https://github.com/encode/django-rest-framework/issues/9358 is fixed.
129 # Otherwise applying blueprints/default/default-brand.yaml fails with:
130 # authentik.flows.models.RelatedObjectDoesNotExist: FlowStageBinding has no target.
131 djangorestframework = prev.buildPythonPackage rec {
132 pname = "djangorestframework";
134 format = "setuptools";
136 src = fetchFromGitHub {
138 repo = "django-rest-framework";
140 hash = "sha256-Fnj0n3NS3SetOlwSmGkLE979vNJnYE6i6xwVBslpNz4=";
143 propagatedBuildInputs = with final; [
148 nativeCheckInputs = with final; [
159 pythonImportsCheck = [ "rest_framework" ];
162 authentik-django = prev.buildPythonPackage {
163 pname = "authentik-django";
164 inherit version src meta;
169 name = "scim-schema-load.patch";
170 url = "https://github.com/goauthentik/authentik/commit/f3640bd3c0ee2f43efcfd506bb71d2b7b6761017.patch";
171 hash = "sha256-4AC7Dc4TM7ok964ztc+XdHvoU/DKyi9yJoz5u1dljEM=";
176 rm lifecycle/system_migrations/tenant_files.py
177 substituteInPlace authentik/root/settings.py \
178 --replace-fail 'Path(__file__).absolute().parent.parent.parent' "Path(\"$out\")"
179 substituteInPlace authentik/lib/default.yml \
180 --replace-fail '/blueprints' "$out/blueprints" \
181 --replace-fail './media' '/var/lib/authentik/media'
182 substituteInPlace pyproject.toml \
183 --replace-fail 'dumb-init = "*"' "" \
184 --replace-fail 'djangorestframework-guardian' 'djangorestframework-guardian2'
185 substituteInPlace authentik/stages/email/utils.py \
186 --replace-fail 'web/' '${webui}/'
189 nativeBuildInputs = [ prev.poetry-core ];
191 propagatedBuildInputs = with final; [
212 djangorestframework-guardian2
220 google-api-python-client
241 swagger-spec-validator
242 tenant-schemas-celery
254 ++ channels.optional-dependencies.daphne
255 ++ django-storages.optional-dependencies.s3
256 ++ opencontainers.optional-dependencies.reggie
257 ++ psycopg.optional-dependencies.c
258 ++ uvicorn.optional-dependencies.standard;
261 mkdir -p $out/web $out/website
262 cp -r lifecycle manage.py $out/${prev.python.sitePackages}/
263 cp -r blueprints $out/
264 cp -r ${webui}/dist ${webui}/authentik $out/web/
265 cp -r ${website} $out/website/help
266 ln -s $out/${prev.python.sitePackages}/authentik $out/authentik
267 ln -s $out/${prev.python.sitePackages}/lifecycle $out/lifecycle
273 inherit (python.pkgs) authentik-django;
275 proxy = buildGoModule {
276 pname = "authentik-proxy";
277 inherit version src meta;
280 substituteInPlace internal/gounicorn/gounicorn.go \
281 --replace-fail './lifecycle' "${authentik-django}/lifecycle"
282 substituteInPlace web/static.go \
283 --replace-fail './web' "${authentik-django}/web"
284 substituteInPlace internal/web/static.go \
285 --replace-fail './web' "${authentik-django}/web"
290 vendorHash = "sha256-BcL9QAc2jJqoPaQImJIFtCiu176nxmVcCLPjXjNBwqI=";
293 mv $out/bin/server $out/bin/authentik
296 subPackages = [ "cmd/server" ];
299 in stdenvNoCC.mkDerivation {
305 patchShebangs lifecycle/ak
307 # This causes issues in systemd services
308 substituteInPlace lifecycle/ak \
309 --replace-fail 'printf' '>&2 printf' \
310 --replace-fail '> /dev/stderr' ""
316 cp -r lifecycle/ak $out/bin/
318 wrapProgram $out/bin/ak \
319 --prefix PATH : ${lib.makeBinPath [ (python.withPackages (ps: [ps.authentik-django])) proxy ]} \
320 --set TMPDIR /dev/shm \
321 --set PYTHONDONTWRITEBYTECODE 1 \
322 --set PYTHONUNBUFFERED 1
326 passthru.outposts = callPackages ./outposts.nix { };
328 nativeBuildInputs = [ makeWrapper ];