{"id":28159710,"url":"https://github.com/leshniak/hass-auth-cookie","last_synced_at":"2025-10-10T11:10:53.652Z","repository":{"id":218922235,"uuid":"747707769","full_name":"leshniak/hass-auth-cookie","owner":"leshniak","description":"Copies Home Assistant access token to a cookie, so you can use an existing authorization result for other subpages or services.","archived":false,"fork":false,"pushed_at":"2025-04-15T11:14:25.000Z","size":106,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-05-15T10:11:40.230Z","etag":null,"topics":["authorization","cookies","homeassistant","homeassistant-plugin","reverse-proxy"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/leshniak.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-01-24T13:37:57.000Z","updated_at":"2025-05-05T12:44:07.000Z","dependencies_parsed_at":null,"dependency_job_id":"69c31e74-3608-4863-b5d3-b95e57bd2bf6","html_url":"https://github.com/leshniak/hass-auth-cookie","commit_stats":null,"previous_names":["leshniak/hass-auth-cookie"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/leshniak/hass-auth-cookie","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leshniak%2Fhass-auth-cookie","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leshniak%2Fhass-auth-cookie/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leshniak%2Fhass-auth-cookie/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leshniak%2Fhass-auth-cookie/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leshniak","download_url":"https://codeload.github.com/leshniak/hass-auth-cookie/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leshniak%2Fhass-auth-cookie/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279003726,"owners_count":26083610,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-10T02:00:06.843Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["authorization","cookies","homeassistant","homeassistant-plugin","reverse-proxy"],"created_at":"2025-05-15T10:11:26.009Z","updated_at":"2025-10-10T11:10:53.637Z","avatar_url":"https://github.com/leshniak.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Home Assistant Auth-Cookie\n\n![Total downloads](https://img.shields.io/github/downloads/leshniak/hass-auth-cookie/total)\n\nCopies Home Assistant access token to a cookie, so you can use an existing authorization result for other subpages or services.\n\nUseful for **zigbee2mqtt**, **frigate** or **go2rtc** panels in a dockerized setup.\n\n## Installation\n**Follow only one of these installation methods.**\n\n\u003cdetails\u003e\n  \u003csummary\u003e\u003cb\u003eInstallation and tracking with HACS:\u003c/b\u003e\u003c/summary\u003e\n\n1. In \"Frontend\" hit the plus button at the bottom right, search for \"Auth Cookie\", and install.\n\n2. Refresh the Dashboard page. You might need to clear the cache.\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003e\u003cb\u003eManual installation:\u003c/b\u003e\u003c/summary\u003e\n  \n1. Copy [hass-auth-cookie.js](https://raw.githubusercontent.com/leshniak/hass-auth-cookie/refs/heads/main/hass-auth-cookie.js) from the latest release into `/www/hass-auth-cookie/`\n\n2. Add the resource in `ui-lovelace.yaml` or in Dashboard Resources.\n\n```yaml\nresources:\n  # increase this version number at end of URL after each update\n  - url: /local/hass-auth-cookie/auth-cookie.js?v=1.0.0\n    type: module\n```\n\n3. Refresh the page, may need to clear cache.\n\u003c/details\u003e\n\n## Usage\n\u003e [!NOTE]\n\u003e It won't work if you enter Home Assistant directly, without proxying by nginx!\n\nAfter an installation, use `hass_access_token` cookie to get the authorization result from [Home Assistant API](https://developers.home-assistant.io/docs/api/rest/). For example, in a dockerized setup, you can use a [`ngx_http_auth_request_module`](https://nginx.org/en/docs/http/ngx_http_auth_request_module.html) from nginx to perform a subrequest, that will secure another proxied service.\n\n**nginx config snippet:**\n```nginx\nlocation / {\n    proxy_pass http://127.0.0.1:8123/; # Home Assistant instance\n    ...\n}\n\nlocation = /_auth {\n    internal;\n    proxy_pass http://127.0.0.1:8123/api/; # Home Assistant API, required\n    proxy_pass_request_body off;\n    proxy_set_header Content-Length \"\";\n    proxy_set_header X-Original-URI $request_uri;\n    proxy_set_header Authorization \"Bearer $cookie_hass_access_token\"; # use an access token from the cookie, required\n}\n\nlocation /_sites/zigbee2mqtt/ {\n    auth_request /_auth; # perform authorization subrequest, required\n    proxy_pass http://127.0.0.1:8080/; # proxied service, eg. zigbee2mqtt frontend\n    ...\n}\n```\n\nNow create a Home Assistant dashboard with a *Webpage* card and put `/_sites/zigbee2mqtt/` in the URL field. It will load your service in an IFRAME:\n\n![HomeAssistant](/screenshot.png)\n\n\n\n## Star History\n[![Star History Chart](https://api.star-history.com/svg?repos=leshniak/hass-auth-cookie\u0026type=Date)](https://star-history.com/#leshniak/hass-auth-cookie\u0026Date)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleshniak%2Fhass-auth-cookie","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleshniak%2Fhass-auth-cookie","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleshniak%2Fhass-auth-cookie/lists"}