authentik icon indicating copy to clipboard operation
authentik copied to clipboard

Custom Templates error while starting Authentik

Open ZeroVEVO opened this issue 1 year ago • 1 comments

Describe the bug The Problem is that Authentik won´t start anymore if I map another /templates folder to the container while using Docker Stack. When mounting /templates to the container from a different loction than ./custom-templates the authentik-server messages "Internal Server Error" while starting and won´t show the Login Page anymore. Error persists. Im Using Docker Stack with Portainer on it so no local ./custom-templates available. We are using an shared NFS Volume here.

To Reproduce Steps to reproduce the behavior:

  1. Deploy a Docker Cluster (Docker Swarm/Stackfile)
  2. Deploy Portainer with yaml file on the cluster
  3. Deploy Authentik with Portainer via Stack Editor yaml file
  4. Mount the volume authentik_templates:/templates. See Logs for detailed volume configuration
  5. Start Stack via Portainer
  6. See error "Internal Server Error" - Logs attached below
  7. if you remove the volume mapping Authetnik starts as normal

Expected behavior I would expect Authentik to start as with no volume attached for templates since the other volume mounts are done the same way and this is no problem. I would expect Authentik to create the templates necessary to start by itself, not rely only on the mapped volume. It seems the moment you map custom templates to /templates the system ignores its default templates as well.

Logs Volume configuration: volumes: - /var/run/docker.sock:/var/run/docker.sock - authentik_media:/media - authentik_certs:/certs - authentik_templates:/templates volumes: authentik_templates: name: authentik_templates driver: local driver_opts: type: nfs o: addr=our-nfs-server,nfsvers=4,rw device: ":/media/authentik-data/templates"

Traceback (most recent call last):

File "/ak-root/.venv/lib/python3.13/site-packages/uvicorn/protocols/http/httptools_impl.py", line 409, in run_asgi

result = await app(  # type: ignore[func-returns-value]

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

    self.scope, self.receive, self.send

    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

)

^

File "/ak-root/.venv/lib/python3.13/site-packages/uvicorn/middleware/proxy_headers.py", line 60, in call

return await self.app(scope, receive, send)

       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/ak-root/.venv/lib/python3.13/site-packages/sentry_sdk/integrations/asgi.py", line 158, in _run_asgi3

return await self._run_app(scope, receive, send, asgi_version=3)

       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/ak-root/.venv/lib/python3.13/site-packages/sentry_sdk/integrations/asgi.py", line 260, in _run_app

raise exc from None

File "/ak-root/.venv/lib/python3.13/site-packages/sentry_sdk/integrations/asgi.py", line 255, in _run_app

return await self.app(

       ^^^^^^^^^^^^^^^

    scope, receive, _sentry_wrapped_send

    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

)

^

File "/ak-root/.venv/lib/python3.13/site-packages/channels/routing.py", line 48, in call

return await application(scope, receive, send)

       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/ak-root/.venv/lib/python3.13/site-packages/django/core/handlers/asgi.py", line 162, in call

await self.handle(scope, receive, send)

File "/ak-root/.venv/lib/python3.13/site-packages/django/core/handlers/asgi.py", line 208, in handle

task.result()

~~~~~~~~~~~^^

File "/ak-root/.venv/lib/python3.13/site-packages/django/core/handlers/asgi.py", line 185, in process_request

response = await self.run_get_response(request)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/ak-root/.venv/lib/python3.13/site-packages/django/core/handlers/asgi.py", line 244, in run_get_response

response = await self.get_response_async(request)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/ak-root/.venv/lib/python3.13/site-packages/django/core/handlers/base.py", line 162, in get_response_async

response = await self._middleware_chain(request)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/ak-root/.venv/lib/python3.13/site-packages/asgiref/sync.py", line 468, in call

ret = await asyncio.shield(exec_coro)

      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/usr/local/lib/python3.13/concurrent/futures/thread.py", line 59, in run

result = self.fn(*self.args, **self.kwargs)

File "/ak-root/.venv/lib/python3.13/site-packages/asgiref/sync.py", line 522, in thread_handler

return func(*args, **kwargs)

File "/ak-root/.venv/lib/python3.13/site-packages/django/core/handlers/exception.py", line 57, in inner

response = response_for_exception(request, exc)

File "/ak-root/.venv/lib/python3.13/site-packages/django/core/handlers/exception.py", line 157, in response_for_exception

response = response.render()

File "/ak-root/.venv/lib/python3.13/site-packages/django/template/response.py", line 114, in render

self.content = self.rendered_content

               ^^^^^^^^^^^^^^^^^^^^^

File "/ak-root/.venv/lib/python3.13/site-packages/django/template/response.py", line 90, in rendered_content

template = self.resolve_template(self.template_name)

File "/ak-root/.venv/lib/python3.13/site-packages/django/template/response.py", line 72, in resolve_template

return select_template(template, using=self.using)

File "/ak-root/.venv/lib/python3.13/site-packages/django/template/loader.py", line 42, in select_template

return engine.get_template(template_name)

       ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^

File "/ak-root/.venv/lib/python3.13/site-packages/django/template/backends/django.py", line 79, in get_template

return Template(self.engine.get_template(template_name), self)

                ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^

File "/ak-root/.venv/lib/python3.13/site-packages/django/template/engine.py", line 177, in get_template

template, origin = self.find_template(template_name)

                   ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^

File "/ak-root/.venv/lib/python3.13/site-packages/django/template/engine.py", line 159, in find_template

template = loader.get_template(name, skip=skip)

File "/ak-root/.venv/lib/python3.13/site-packages/django/template/loaders/cached.py", line 57, in get_template

template = super().get_template(template_name, skip)

File "/ak-root/.venv/lib/python3.13/site-packages/django/template/loaders/base.py", line 23, in get_template

contents = self.get_contents(origin)

File "/ak-root/.venv/lib/python3.13/site-packages/django/template/loaders/cached.py", line 26, in get_contents

return origin.loader.get_contents(origin)

       ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^

File "/ak-root/.venv/lib/python3.13/site-packages/django/template/loaders/filesystem.py", line 22, in get_contents

with open(origin.name, encoding=self.engine.file_charset) as fp:

     ~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

PermissionError: [Errno 13] Permission denied: '/templates/if/error.html'

Version and Deployment (please complete the following information):

  • authentik version: [e.g. 2025.6.3]
  • Deployment: [docker-compose / stackfile, docker swarm engine 28.3.0, portainer 2.27.9 LTS]

Additional context As soon as we dont map the /templates the problem is solved but we want to add an email template. As mentioned, other mappings via NFS are fine, same user rights applied.

ZeroVEVO avatar Jul 10 '25 12:07 ZeroVEVO

Never mind, I could solve the problem with setting the folder /templates on the NFS to chmod a+rx. After reboot the folder worked.

ZeroVEVO avatar Jul 10 '25 13:07 ZeroVEVO