Task Pane AuthenticationΒΆ
By setting XLWINGS_AUTH_PROVIDERS in the Settings, xlwings Server will authenticate calls to Custom Functions and Custom Scripts. Since the task pane is completely customizable, it is your responsibility to lock down the desired endpoints:
The landing page of the task pane needs to be publicly available
The rest of the pages can be locked down using the
Userdependency injection (using a custom router viauv run xlwings-server add router):from fastapi import APIRouter, Request from xlwings_server import settings, dependencies as dep from xlwings_server.templates import TemplateResponse router = APIRouter(prefix=settings.app_path) @router.get("/taskpane/protected") async def taskpane_protected(request: Request, current_user: dep.User): return TemplateResponse( request=request, name="examples/auth/protected.html", context={"current_user": current_user}, )
You will need to provide the
Authorizationheader with every request. Forhtmx, there is a sample included underxlwings_server/templates/examples/auth.