A Home Assistant custom integration that blocks login attempts from external networks while allowing existing authenticated sessions to work from any location.
Easier than VPN or Cloud Flare tunnel. Install, enable and it will work for your whole family!
- Blocks new login attempts (
/auth/login_flow,/auth/authorize) from IP addresses outside your configured local networks - Existing sessions, token refreshes, API calls, and WebSocket connections continue to work from any IP
- Nabu Casa cloud connections are not affected (they appear as local)
POST /auth/token(token refresh) -- existing sessions keep working- All authenticated API and WebSocket requests
- Any request originating from a configured local network IP
- Open HACS in your Home Assistant instance
- Click the three dots in the top right corner and select Custom repositories
- Add
https://github.com/raivisdejus/ha-disable-external-loginwith category Integration - Search for Disable External Login in the list of available repositories on HACS
- Click Download
- Restart Home Assistant
- Copy the
custom_components/disable_external_loginfolder into your Home Assistantconfig/custom_components/directory - Restart Home Assistant
- Go to Settings > Devices & services
- Click + Add integration
- Search for Disable External Login
- Configure:
- Enable external login blocking -- toggle on/off
- Local networks -- add CIDR entries for your local networks (e.g.,
192.168.1.0/24,10.0.0.0/8)
- Submit
Default local networks (RFC 1918 + loopback):
127.0.0.0/810.0.0.0/8172.16.0.0/12192.168.0.0/16::1/128fd00::/8fe80::/10
Settings can be changed at any time via Configure on the integration card without restarting Home Assistant.
The integration installs an aiohttp middleware into the Home Assistant HTTP server. The middleware checks request.remote (resolved by HA's forwarded middleware using trusted proxy configuration) against the configured local network CIDRs. Requests to login endpoints from non-local IPs receive a 403 response.
- Home Assistant 2024.1.0 or newer
- Trusted proxies must be correctly configured in
configuration.yamlif running behind a reverse proxy, so thatrequest.remotereflects the real client IP
Made with Claude Code. If you find this integration useful, please star the repository 🌟