Authentication Issues when Creating a Web-based Integration for Home Assistant

Hello, I am currently trying to create a web-based integration for Home Assistant. However, I always receive a 401: Unauthorized error when I try to reach the endpoint, even when it is embedded in an iframe. If I disable authentication, I do not have the hass_user object in the request. Here is a minimal example to test authentication.

I would like to have only authentikated users access this web interface via the sidebar i currently do this via an iframe in the configuration but i would like to add it via the integration itself.